Integrating Selenium Webdriver with Katalon Studio

Hi,

I have written java code in selenium web-driver for running the test in different devices.
Please let me know how i can use that in Katalon Studio.
I have tried creating it as a custom keyword, but while trying to call test case inside the selenium code it is throwing error.

Please help me.
Used the below code
@Keyword

def refreshBrowser() {

Map<String, String> mobileEmulation = new HashMap<>();

mobileEmulation.put(“deviceName”,“iPhone 6”);

ChromeOptions chromeOptions = new ChromeOptions();

chromeOptions.setExperimentalOption(“mobileEmulation”, mobileEmulation);

WebDriver driver = new ChromeDriver(chromeOptions);

//// WebUI.callTestCase(“Header Logo”, driver);-- Throwing error in this statement

}

}

1 Like

What error are you getting?

This is the error i am getting while executing the above code.

Test Cases/Testing Mobile simulator FAILED because (of) org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.callTestCase() is applicable for argument types: (java.lang.String, org.openqa.selenium.chrome.ChromeDriver) values: [Header Logo, ChromeDriver: chrome on MAC (06ae28698933dcf35b5387795689313c)]

Possible solutions: callTestCase(com.kms.katalon.core.testcase.TestCase, java.util.Map), callTestCase(com.kms.katalon.core.testcase.TestCase, java.util.Map, com.kms.katalon.core.model.FailureHandling)

https://docs.katalon.com/display/KD/Call+test+case

The second parameter of WebUI.callTestCase() is wrong. Why are you sending ‘driver’ to the “Header Logo” TC? Can you share the “Header Logo” code?

I want the “Header Logo” test case to run in the Iphone 6 chrome simulator(Using the above selenium code) thats why i have passed the driver parameter inside the call test case method

Also I have tried adding custom capabilities by adding chrome simulator in Katalon Studio settings, but that doesnt work thats why I have used the selenium code for running tests in chrome simulator

Header Logo code

WebUI.openBrowser(‘https://ausopen.com/’)

WebUI.verifyElementPresent(findTestObject(‘Page_Australian Open - Logo validation in the landing page/Logo’), 5)

WebUI.verifyElementPresent(findTestObject(‘Page_Australian Open - Logo validation in the landing page/Date’), 5)

WebUI.closeBrowser()

Please let me know if there is any solution for implementing “driver code” into call test case method(header logo).

I need to run my test cases in different devices using chrome simulator.

So, you are not sending ‘driver’ as a parameter?

What happens if you try to run WebUI.callTestCase(“Header Logo”, [:])

Please help me

I want “Header Logo” to run in chrome simulator, so I passed the “driver” as a parameter into call Test case method like below.

WebUI.callTestCase(“Header Logo”, driver)

But getting error while executing it.

Please let me know if there is any way for running my Katalon test cases in driver code (Chrome simulator)

WebUI. callTestCase works fine if i declare the parameters correctly without using driver(my chrome simulator code), but not working if I try to include Driver as a parameter inside callTestcase method.

1. What your error is saying is that you are trying to pass a ChromeDriver parameter where java.util.Map type is expected.
2. I can’t see why are you trying to pass the ‘driver’ to “Header Logo”, it is not even mentioned in the code?

Hi Mate,

I m trying to run Header Logo code in chrome simulator(Chrome driver) using call test case method.
I dont know what method I should use for calling the other test case into chrome driver code, so I used calltestcase method.

I have used the below seleinum code in eclipse for chrome simulator, to launch Google site in IPHONE X simulator, so I thought i can use the same code in Katalon for running my tests, but I really dont know how to pass my tests as a parameter into selenium code(Chrome driver)

class differentbrowser {

@Keyword

def refreshBrowser() {

Map<String, String> mobileEmulation = new HashMap<>();

mobileEmulation.put(“deviceName”,“iPhone X”);

ChromeOptions chromeOptions = new ChromeOptions();

chromeOptions.setExperimentalOption(“mobileEmulation”, mobileEmulation);

WebDriver driver = new ChromeDriver(chromeOptions);

driver.get(“www.google.com”)

}

}

Please let me know if there is any method/solution for running my tests using the above chrome driver

Bargavi said:

I want the “Header Logo” test case to run in the Iphone 6 chrome simulator(Using the above selenium code) thats why i have passed the driver parameter inside the call test case method

Also I have tried adding custom capabilities by adding chrome simulator in Katalon Studio settings, but that doesnt work thats why I have used the selenium code for running tests in chrome simulator
https://www.screencast.com/t/o4cwA4pv

Header Logo code

WebUI.openBrowser(‘https://ausopen.com/’)

WebUI.verifyElementPresent(findTestObject(‘Page_Australian Open - Logo validation in the landing page/Logo’), 5)

WebUI.verifyElementPresent(findTestObject(‘Page_Australian Open - Logo validation in the landing page/Date’), 5)

WebUI.closeBrowser()

What I meant was - there is no need to explicitly reference the driver in your Header Logo code.
So you can just call test case with WebUI.callTestCase(“Header Logo”, [:]).

If i use callTestcase method **"**WebUI.callTestCase(“Header Logo”, [:])" in custom keyword test case will it run in chrome simulator(driver code) or in normal browser (chrome)?

I need not explicitly declare the driver code inside calltestcase method?

import com.kms.katalon.core.webui.driver.DriverFactory
@Keyword
def refreshBrowser() {
    Map<String, String> mobileEmulation = new HashMap<>()
    mobileEmulation.put("deviceName","iPhone 6")
    ChromeOptions chromeOptions = new ChromeOptions()
    chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
    WebDriver driver = new ChromeDriver(chromeOptions)    // Bargavi, you need this line.    DriverFactory.changeWebDriver(driver)
    WebUI.callTestCase("Header Logo", [:])}

Here is a similar post

Thanks alot for your help.

I have tried the above code and it works.