I have been using Katalon for a couple days now for both writing mobile and web tests. Most of my use cases depend on a combination of the two, where a user logs in on mobile device, does some actions that generate a CTA for an admin user to approve/reject via web. I can run both test cases independently and all goes well, but I’m looking for a way to combine them. I can think of 2 options how to do so:
Have 1 test that first runs the mobile part, followed by the webui test.
have 2 separate tests and place them in a test suite so first test A runs and after that test B
The problem is that I need some way to configure the testcases to appoint how to run them (Mobile is running on emulator in android studio and webui is running on chrome).
Possibly you can make a Test Case of option1 type that first runs the mobile part followed by the webui test.
You would create a Test Case TC0 for mobile part only, without any webui part
You would choose “Android emulator” to run the TC0 with
Later you want to edit the TC0. You want to add the webui part.
You should know a thing: You do not necessarily have to use WebUI.openBrowser() to open a browser. There is an alternative way to open a browser programatically
The only question is how the TC0 can instanciate a ChromeDriver = how it can open Chrome browser and continue interating with the Chrome browser using WebUI.* keywords.
You can do it. See the following post:
You would call new ChromeDriver(options) in the TC0. TC0 will open a Chrome browser window. You want to call DriverFactory.changeWebDriver(driver). This will make all successive calls to WebUI.* keywords to interact with the Chrome opened by new ChromeDriver() call.
Please note: You would run the TC0 with choosing Android emulater. You can forget Chrome when you start the TC0. Regardless which Driver type you chose in the Katalon Stuio GUI, TC0 will launch Chrome by calling new ChromeDriver() explicitly.
This project was developed using Katalon Studio v9.3.1.
Problem to solve
The original poster wanted to write a Test Case script that execute a Mobile test first followed a WebUI test. However he wondered:
How to choose Android rather than iPhone to run his Mobile test.
How to choose Chrome on PC rather than Firefox or Edge to run his WebUI test.
Katalon Studio is not designed with such usecases in mind. Katalon Studio requires us choose a single browser to run a Test Case with. We can choose Chrome for a WebUI test; we can choose Android for a Moble test. But the original poster wants both of Chrome and Android for a single Test Case.
// run Mobile test
Mobile.callTestCase(findTestCase("Verify Last Items In List"), null)
// run WebUI test while launching PC Chrome browser explicitly without calling WebUI.openBrowser('')
WebUI.callTestCase(findTestCase("Verify Login CURA System - PC Chrome Browser"), null)
The Combinator combines two scripts in a sequence. It calls a Mobile test first, and soon after that it calls a WebUI test.
I would launch the Combinator while choosing Android. I would not mind Chrome here.
The Combinator Test Case successfully worked for me. It ran a Mobile App on my Android phone, and after that it opened Chrome browser and visited http://demoaut.katalon.com .
//WebUI.openBrowser(GlobalVariable.G_SiteURL)
// We want to launch PC Chrome browser explicity
System.setProperty("webdriver.chrome.driver", "/Applications/Katalon Studio.app/Contents/Eclipse/configuration/resources/drivers/chromedriver_mac/chromedriver")
WebDriver driver = new ChromeDriver()
DriverFactory.changeWebDriver(driver)
WebUI.navigateToUrl(GlobalVariable.G_SiteURL)
I commented out the line of WebUI.openBrowser keyword.
I launched Chrome browser using ChromeDriver API.
By this change, the Verify Login CURA System - PC Chrome Browser script will ALWAYS run with Chrome browser regardles which type of browser I chose when I start the test case. Even if I chose Android, the Verify Login CURA System - PC Chrome Browser will run with PC Chrome.
The problem is resolved.
Applicability
This project proved that we can write a Test Case that performs Mobile testing and WebUI testing combined. Katalon Studio is not designed to support such unusual cases. The trick is that the Test Case should open a PC browser using the WebDriver’s native API without using WebUI.openBrowser keyword.
I could find other topics in the Katalon forum that wants a way to combine WebUI testing and Mobiel/Desktop testing.
I can imagin a code Test Cases/CombinatorUsingExtendedKeyword which uses callTestCase with a new method signature:
(Please note, the following code will NEVER work! I just hoped it.)
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.webui.driver.WebUIDriverType as DriverType
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
/**
* "Test Cases/CombinatorUsingExtendedKeyword"
*/
// run Mobile test
Mobile.callTestCase(findTestCase("Verify Last Items In List"), null)
// run WebUI test with Chrome
WebUI.callTestCase(DriverType.CHROME_DRIVER, findTestCase("Verify Login CURA System Successfully - Mobile Browser"), null)
Please find that WebUI.callTestCase(DriverType.CHROME_DRIVER, ..." accepts the type of WebDriver as the 1st argument. In the above code snippet, I specified DriverType.CHROME_DRIVER for the Test Case “Verify Login CURA System Successfully - Mobile Browser”. The first argument DriverType.CHROME_DRIVER would play a role just the same as the case where I chose Chrome in the Katalon GUI to run the test case script with.
I hope this code to work. This code looks clean. It clearly illustrates what I want to do.