Correct.
Java 8.
Yes. In fact, most of Katalon’s built-in keywords are based on selenium.
Correct.
Java 8.
Yes. In fact, most of Katalon’s built-in keywords are based on selenium.
Thank you, ThanhTo and Brandon!
If I import Selenium API jar in my tests how I can get the same instance of WebDriver that’s used by the script. I mean, as far as I understand, the following code based on Selenium, which means it uses an instance of WebDriiver
WebUI.openBrowser(‘’)
WebUI.navigateToUrl(‘https://google.com/’)
So the questions are
Thanks!
Yes.
WebDriver driver = DriverFactory.getWebDriver();
It will work. I don’t know what it will look like in Manual view, but TBQH, if you’re familiar with Java, you may find that using the Script view is much better anyway. I personally never use Manual view.
Thank you for your help, Brandon! I was not sure because I’m not even new to Katalon yet (just started looking into it) and was thinking that maybe only keywords can be used in the tests.
One more question. How exactly to import Selenium API jar in my test case and/or custom keyword as per
Thanks
You can just do whatever you normally do in Java.
Type WebElement
and then hit Ctrl + Shift + O
for auto import of Selenium class. Same goes for other usage.
If you’ve ever used Eclipse IDE, then as ThanhTo said, just use the auto-import hotkey ctrl + shift + o. Katalon Studio is built on top of Eclipse, so all/most of the same hotkeys will work.
Thank you for your help, ThanhTo and Brandon!
I liked Katalon from the first sight and thanks to your help it looks like I’m going to fall in love with it
Thank you for your help Brandon! It works.
My apologies. Yes, it should be DriverFactory. I will update my original reply.
I would like to know if we can use JAVA to do stubs inside Katalon, to make a message simulator from another sytem and use it inside as part of the script.
Like: I do actions, I call my mock, stuband I continue my web actions.
Thank you !
Java/Groovy code can be put inside a Custom Keyword and then the keyword can be used as test steps in your test case, so if you’ve successfully stubbed things outside of Katalon, you should be able to do the same within Katalon.
Wow! this really is helpful! Thanks, Arnel!
Not only in the Keywords
directory, you can locate *.java and *.groovy source codes under the Include/scripts/groovy
.
A *.java example is here:
The Include/scripts/groovy
directory was introduced sometime in ver 5.* years ago for the sake of testing driven by Cucumber.
https://docs.katalon.com/katalon-studio/docs/cucumber-features-file.html#define-steps
You can write Cucumber test in either of Java and Groovy.
Let me add my words a bit.
The Include/scripts/groovy
is just inserted to the Eclipse .classpath
setting of Katalon Studio overall. Therefore you can actually locate any *.groovy and *.java code there regardless if they are Cucumber driven or not.
What is the difference between the Keywords
directory and the Include/scripts/groovy
then? — I can point out only one possible difference. The classes under the Keywords
can be annotated with @Keyword
annotation and will be treated as Custom Keywords in the GUI of Manual Mode of Test Case Editor.
Classes under the Include/scripts/groovy
may not be regarded as Custom Keywords, though I have not tested it yet as I do not use the Manual Mode at all.
Can write script in java with having file extension. Java? If yes then how to achieve it in katalon studio?
That’s all.
Your question is ambiguous. Please try whatever you want to do in Katalon Studio. If you got error, please describe it. That would tell others what you want to achieve. Then people may advise you something.
Ok. Let me make it simple. I want to create test case and that should have an .java extension. Currently when we navigate to file explorer we see the . groovy file of test script but i want it to be in . java
No, you can’t do it.
I don’t believe it can be a .java file, but it can certainly be a .groovy file with 100% java code in it. The groovy compiler accepts Java completely (with only a couple of distinct exceptions).
Yes, the compiler does. But it is not a right answer to @nitin.bhoyar .
See the following example.
I made a test case named “HelloJava”, which contains the following lines:
public class HelloJava {
public static void main(String[] args) {
System.out.println("Hello, Java");
}
}
This code is completely valid in Java language syntax and semantics. When I clicked the run button for this test case, Katalon Studio refused to run it.
This single example is enough to prove that Katalon Studio does not allow you to write a Test Case in Java.