1 / 10

Appium TestNG Framework and Multi-Device Automation Execution

TestNG with Appium is one of the most popular choices among Automation engineers when it comes to Mobile App Automation. TestNG eliminates most of the limitations of the older framework and gives the developer the ability to write more flexible and powerful tests with help of easy annotations, grouping, sequencing & parameterizing. <br>https://www.pcloudy.com

pcloudy
Download Presentation

Appium TestNG Framework and Multi-Device Automation Execution

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Configuring TestNG Framework For Multi-Device Execution By Nilesh Tarale, Anshuman

  2. A Typical Evolution of Test Framework - 1 • Stage-1:Driver Script + Tool = Results in Console • Stage-2:Driver Script + Data + Tool = Execution Report + Snapshots • Stage-3:Driver Script + Data + Objects + Tool = HTML Report + Snaps + Logs • Stage-4:Multiple process in parallel of the same automation code • And now, the Problems...

  3. A Typical Evolution of Test Framework -2 Problems in Stage - 3 & 4 • Creation (& Maintenance) of Data & Object Driven Framework and Reporting & Logging Frameworks. • Every process (for parallel executions) consume memory • Consolidated Reports not achieved, only individual reports • FileHandling I/O Errors while creation of log files, reports & snapshots • Stage-5:Multiple processthreads in parallel of the sameautomation code. This resolves #2, #3

  4. A Typical Evolution of Test Framework -3 Problems in Stage-5 (Multithreading) !!!Code not Thread Safe!!! The driver object & many other things are kept static. Which means, they can be accessed without instantiating a class and are like shared variables. • Solution(mostly): Lets live with the problems of Stage-4. • Thus, the concept of parallel testing remains in a PoC stage for most of the organizations.

  5. Introduction of TestNG Framework Groupings publicclass Grouping { @Test (groups = {"Car"})publicvoid Car1() { SYSO("Test car 1");} @Test (groups = {"Car"})publicvoid Car2() { SYSO("Test car 2");} @Test (groups = {"Scooter"})publicvoid Scooter1() { SYSO("Test scooter 1");} @Test (groups = {"Scooter"})publicvoid Scooter2() { SYSO("Test scooter 2");} @Test (groups = {"Car", "Sedan Car"})publicvoid Sedan1() { SYSO("Test sedan 1");}} Annotations @BeforeSuite @BeforeTest @BeforeClass @BeforeMethod @Test @Test @Test @AfterMethod @AfterClass @BeforeClass @BeforeMethod @Test @Test @Test @AfterMethod @AfterClass @AfterTest @AfterSuite Depends On publicclass Dependent { @Test (dependsOnMethods = {"OpenBrowser"})publicvoidSignIn() { SYSO("This will execute second (SignIn)");} @TestpublicvoidOpenBrowser() { SYSO("This will execute first (Open Browser)");} @Test (dependsOnMethods = {"SignIn"})publicvoidLogOut() { SYSO("This will execute third (Log Out)");} } Reference:http://toolsqa.com/selenium-webdriver/testng-annotations-groups-depends/

  6. TestNG: Sequencing/Prioritizing, Skipping & Parameterization Sequencing & Prioritizing publicclassMultipleTest{ @Test(priority = 0)publicvoid One() {System.out.println("This is the Test Case number One");} @Test(priority = 1)publicvoid Two() {System.out.println("This is the Test Case number Two");} @Test(priority = 2)publicvoid Three() {System.out.println("This is the Test Case number Three");} @Test(priority = 3)publicvoid Four() {System.out.println("This is the Test Case number Four");}} Skipping publicclassMultipleTest{ @Test(priority = 0)publicvoid One() {System.out.println("This is the Test Case number One");} @Test(priority = 1)publicvoid Two() {System.out.println("This is the Test Case number Two");} @Test(priority = 2, enabled = false)publicvoid Three() {System.out.println("This is the Test Case number Three");} @Test(priority = 3)publicvoid Four() {System.out.println("This is the Test Case number Four");}} Parameterization publicclassDataParameters{ @Test(dataProvider = "Authentication") publicvoid test(String sUsername, String sPassword ) { SYSO(“Username:” + sUsername); SYSO(“Password:” + sPassword); } @DataProvider(name = "Authentication")publicstatic Object[][] credentials() { returnnew Object[][] { {"testuser_1", "Test@123"}, {"testuser_1", "Test@123"} };} } Reference: http://toolsqa.com/selenium-webdriver/testng-parameters-data-provider/

  7. TestNG: Cross Browser & Parallel Testing Cross Browser publicclassMultiBrowser{private WebDriver driver; @Parameters("browser") @BeforeClass//Browser parameter from TestNG xmlpublicvoidbeforeTest(String browser) { }} <suite name="Suite" parallel="none"> <test name="FirefoxTest"> <parameter name="browser" value="firefox" /> <classes> <class name="MultiBrowser" /> </classes> </test> <test name="IETest"> <parameter name="browser" value="ie" /> <classes> <class name="MultiBrowser" /> </classes> </test> </suite> Dynamically choosingBrowsers / Mobile Devices ? Parallel Testing publicclassMultiBrowser{private WebDriver driver; @Parameters("browser") @BeforeClass//Browser parameter from TestNG xmlpublicvoidbeforeTest(String browser) { }} <suite name="Suite" parallel="tests"> <test name="FirefoxTest"> <parameter name="browser" value="firefox" /> <classes> <class name="MultiBrowser" /> </classes> </test> <test name="IETest"> <parameter name="browser" value="ie" /> <classes> <class name="MultiBrowser" /> </classes> </test> </suite> Reference: http://toolsqa.com/selenium-webdriver/testng-multi-browser-cross-browser/

  8. Dynamically choosing Browsers/Mobile Devices There is a (hidden) feature in TestNG, that is not covered in most of the blogs/help documents. TestNGtng = new TestNG(); XmlSuite suite = newXmlSuite();suite.setName("testNgSuite");XmlTest test = newXmlTest(suite);test.setName("testNgTest");List<XmlClass> classes = newArrayList<XmlClass>();classes.add(newXmlClass("com.mycompany.test.Signup")); classes.add(newXmlClass("com.mycompany.test.Login")); classes.add(newXmlClass("com.mycompany.test.Logout"));test.setXmlClasses(classes) ;//And then you can pass thisXmlSuite to TestNG:List<XmlSuite> suites = newArrayList<XmlSuite>();suites.add(suite);TestNGtng = newTestNG();tng.setXmlSuites(suites);tng.run(); • Reference: http://roadtoselenium.blogspot.in/2014/08/generate-testngxml-dynamically_57.html

  9. How do we do it in pCloudy

  10. Q & A

More Related