Last week, I evaluated Apexon framework (ISFW) and Sauce on Demand (SOD) integration. My main concern was to test not only the integration, but also to verify parallel execution of test that is supported by ISFW and SOD. I found that it worked without any additional efforts along with all benefits of the framework including parallel execution and auto screenshots. In this blog, I will provide details on integration and how to configure your test to run on SOD.
Preface:
Testing web applications often requires running tests against multiple browsers and in multiple environments. Using ISFW, one can run tests on a local or a remote physical machine. For that, you need to set server, port and browser in the properties file. You can configure to execute test in parallel with different options. Furthermore, you can configure your test to run in parallel on distributed servers in different environment as well. If you are using distributed servers, then the only requirement is that selenium server must be running on a remote machine. We have implemented this for some of our clients. ISFW supports overriding server, port and browser properties from configuration file by providing appropriate parameters at suite/test/package/class level. Thus, you can configure multiple server-browser combinations.
Sauce on demand Integration
To run test on cloud with ISFW, all you need to change is the server, port and browser info provided by sauce labs. You can run your test in one or more environments without having your own infrastructure. The most powerful feature of ISFW is that it provides parallel-ready test harness to connect tests to Sauce Labs’ service. As ISFW can run tests in parallel in multiple threads you can achieve parallelism with SOD as well. To use multiple environments/browsers you just need to override browser parameter in the configuration file.
One common issue is related to json string for browser, faced when you want to set browser from xml configuration file. Normally, value of the browser parameter in the configuration file is a string like *firefox, *iehta, etc. But, for SOD you need to provide json string which contains double quotes (“). So, it will not work as parameter value.To overcome this limitation you can provide any property, defined in properties file, as browser parameter value. It’s really helpful that ISFW supports browser parameter value as property!..
Benefits:
- By using Sauce Labs’ service you don’t required to setup different environments.
- With ISFW, no additional efforts are required to run your test using Sauce Labs’ service
- Get all benefits of the IS framework, including parallel execution and auto screenshots.
Those who are interested getting details of the code and configuration used for evaluation, see Code: test-cases used for evaluation, Configuration 1 and Configuration 2. You might also be interested in reading an informative blog on Selenium UI test automation with zero infrastructure cost authored by Akhil.
Code: test-cases used for evaluation.
package com.sample.automation.tests; import… /** * Demo on how to write quick tests. * These test not uses {@link TestPage} implementation provided by FW. * @author chirag */ public class Demo extends BaseTestCase { @Test(description = “Sample test”) public void TCtest() throws Exception { final IsSelenium selenium = getSTB().getSelenium(); WaitService waitService = new WaitService(); selenium.open(“/”); selenium.type(“q”, “apexon automation framework”); selenium.click(“btnG”); selenium.click(“link=glob:*Automation Framework”); // selenium.waitForPageToLoad(“5000”); waitService.waitForPageToLoad(); getSTB().assertEquals(“Apexon Test Automation Framework”, selenium.getText(“css=h1.entry-title”), “Heading”); } /** @Test(description = “Sample data driven test from above one”, dataProvider = “csvDataProvider”, dataProviderClass = DataProviderUtil.class) public void TCDataDriven(String query, String linkloctoverify) throws Exception { } @Test(description = “using property from property file”) final IsSelenium selenium = getSTB().getSelenium();selenium.open(“/”); } } |
Data File
TCDataDriven is data driven test and the searchText.csv data file provided with following entries. So TCDataDriven will execute in separate threads for each data set, results in 3 tests running parallel.
Qmetry,css=a[href*=www.qmetry.com]Apexon,css=a[href*=s40886.p1615.sites.pressdns.com]
apexon selenium,css=a[href*=s40886.p1615.sites.pressdns.com] |
Configuration
Configuration 1:
Here are the settings to run test in windows environment with Firefox. With this configuration data driven test will get executed in parallel.
Properties:
selenium.server=ondemand.saucelabs.com selenium.port=80 selenium.defaultBrowser={“username”: “cjayswal”,\ “access-key”: “????????-????-????-????-????????????”,\ “os”: “Windows 2003″,\ “browser”: “firefox”,\ “browser-version”: “3.6”,\ “name”: “This is an example test”} |
Configuration file:
<!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”> <suite name=“Sample Test Automation” verbose=“0” data-provider-thread-count=“10”> <test name=“Sample Test”> <packages> <package name=“com.sample.automation.tests”/> </packages> </test> </suite> |
Configuration 2:
Configuration to run test in IE8, FF on Windows and FF on Linux. Attribute parallel=“tests” will execute each xml test in separate thread which in turn executes data driven test in parallel (check the time stamp in attached report).
Configuration file:
<!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”> <suite name=“Sample Test Automation” verbose=“0” parallel=“tests” data-provider-thread-count=“10” > <test name=“Test on Win2003 FireFox3.6” > <parameter name=“browser” value=“sauce.json.firefox” /> <packages> <package name=“com.sample.automation.tests”/> </packages> </test> <test name=“Test on Win2003 IE8”> <parameter name=“browser” value=“sauce.json.iehta”/> <packages> <package name=“com.sample.automation.tests”/> </packages> </test> <test name=“Test on Linux FireFox3.6”> </suite> |
Properties:
selenium.server=ondemand.saucelabs.comselenium.port=80 sauce.json.firefoxOnLinux={“username”: “cjayswal”,\ “access-key”: “????????-????-????-????-????????????”,\ “os“: “Linux“,\ “browser”: “firefox“,\ “browser-version”: “3.6”,\ “name”: “Parallel run evaluation with Apexon fw“} sauce.json.firefox={“username”: “cjayswal”,\ sauce.json.iehta={“username”: “cjayswal”,\ |