Running test on cloud with Apexon Test Automation Framework

Reading Time: 11  min

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”);

}

/**
* Data driven test that aspect csv data file. The file path must be set
* using property
<code>test.TCDataDriven.datafile</code>

*
@param query
*
@param linkloctoverify
*
@throws Exception
*/

@Test(description = “Sample data driven test from above one”, dataProvider = “csvDataProvider”, dataProviderClass = DataProviderUtil.class)

public void TCDataDriven(String query, String linkloctoverify) throws Exception {
final
IsSelenium selenium = getSTB().getSelenium();
selenium.open(
“/”);

selenium.type(
“q”, query);

selenium.click(
“btnG”);

getSTB
().verifyElementPresent(linkloctoverify,
“Search result”);

}

@Test(description = “using property from property file”)
public
void propTest() {

final IsSelenium selenium = getSTB().getSelenium();selenium.open(“/”);
selenium.type(props.getPropertyValue(“search.txt.loc”, “q”),”apexon automation framework”);
selenium.click(
props.getPropertyValue(“search.submit.loc”, “btnG”));

selenium.click(
“link=glob:*Automation Framework”);

}

}

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”>
<
parameter name=“browser” value=“sauce.json.firefoxOnLinux”/>
<
packages>
<
package name=“com.sample.automation.tests”/>
</
packages>
</
test>

</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”,\
“access-key”
: “????????-????-????-????-????????????”,\
os
: “Windows 2003″,\
“browser”
: firefox“,\
“browser-version”
: “3.6”,\
“name”
: “Parallel runevaluationwithApexonfw“}

sauce.json.iehta={“username”: “cjayswal”,\
“access-key”
: “????????-????-????-????-????????????”,\
os
: “Windows 2003″,\
“browser”
: iehta“,\
“browser-version”
: “8”,\
“name”
: “Parallelrun evaluation withApexonfw“}

Screenshots:

Report: overview
Report: Test on Win2003 FireFox3.6

package com.sample.automation.tests;

import

/**

* Demo on how to write quick tests.

* These test not uses {@link TestPage} implementation provided by FW.

* You can also utilize IDE plugin for InfoStrech framework.

*

* @author chirag

*/

publicclass Demo extends BaseTestCase {

@Test(description = “Sample test”)

publicvoid 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”);

}

/***

* Data driven test that aspect csv data file. The file path must be set

* using property <code>test.TCDataDriven.datafile</code>

*

* @param query

* @param linkloctoverify

* @throws Exception

*/

@Test(description = “Sample data driven test from above one”, dataProvider = “csvDataProvider”, dataProviderClass = DataProviderUtil.class)

publicvoid TCDataDriven(String query, String linkloctoverify) throws Exception {

final IsSelenium selenium = getSTB().getSelenium();

selenium.open(“/”);

selenium.type(“q”, query);

selenium.click(“btnG”);

getSTB().verifyElementPresent(linkloctoverify, “Search result”);

}

@Test(description = “using property from property file”)

publicvoid propTest() {

final IsSelenium selenium = getSTB().getSelenium();

selenium.open(“/”);

selenium.type(props.getPropertyValue(“search.txt.loc”, “q”),

“apexon automation framework”);

selenium.click(props.getPropertyValue(“search.submit.loc”, “btnG”));

selenium.click(“link=glob:*Automation Framework”);

}

}

Stay Updated
Please enable JavaScript in your browser to complete this form.
LinkedIn
Share
Copy link
URL has been copied successfully!

Other stories you may enjoy...

Healthcare Apps and the Need for Security

One of the most exciting areas in tech right now promises to be “the most personal” ever. A key aspect of making wearable devices like the Apple Watch personal is through...

Developing an App for the 2020 General Election?

Here is a thought: With the UK General Election having just finished, could the next one in 2020 be the first to use a mobile app to allow people to vote? The polling...

Be honest. Describe the state of your test cases.

“There’s some dead wood in there.” “Hmmm…. Someone really needs to clean them up.” “A little outdated.” For those reading this in the northern hemisphere,...