Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Automation Frame works Instruction Sheet

307 views

Published on

Follow the steps to create Test Framework using TenstNG, Modeling Framework using Page Object Modeling and Test Driving Framework using Data Driven

Published in: Technology
  • Work at home: https://saidbenrida.blogspot.com/ https://saidbenrida-best.blogspot.com/ https://saidbenrida-opp.blogspot.com/ https://saidbenrida-recommended.blogspot.com/ https://saidbenrida-trusted.blogspot.com/ https://trusted-saidbenrida.blogspot.com/ http://www.saidbenrida.ws/ https://ewallet-worldwide.tumblr.com/ https://concsaid.blogspot.com/ https://copsaid.blogspot.com/ https://domasaid.blogspot.com/ https://hostsaid.blogspot.com/ https://paysaid.blogspot.com/ https://wsmoney.blogspot.com/
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Automation Frame works Instruction Sheet

  1. 1. XtremeTesting ThoughtWorks src src test main java java search login orders testresources pageobjects steps util Instructions # Create a project Create a maven project with below dependencies <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.9.13.6</version> </dependency> <dependency> <groupId>com.beust</groupId> <artifactId>jcommander</artifactId> <version>1.48</version> </dependency> </dependencies> # Create Below Folder structure # Write TestNG Tests Login Tests @Test public void verifyValidLogintoSpree()
  2. 2. XtremeTesting ThoughtWorks { // add code } @Test public void verifyInvalidLogintoSpree() { //add code } # Create testng xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="Regression"> <test name="regression"> <classes> <class name="login.LoginTest"/> <class name="search.SearchProductsTest" /> </classes> </test> </suite> # ExecuteTests java -cp <tests classes path>:<test ng jar path>:<jcommander jar path> org.testng.TestNG testng.xml #Tag tests and Set Priority Add it to xml <groups> <run> <include name="regression" /> <exclude name="sanity" /> </run> </groups>
  3. 3. XtremeTesting ThoughtWorks Add it to tests @Test(groups = {"smoke"}, priority = 2) # Set Before suite and After Suite @BeforeSuite public void verifyBeforeSuite() { DriverManager manager = new DriverManager(); } # Create Page Objects public class HomePage { @FindBy(how= How.LINK_TEXT, using = "MY ACCOUNT") WebElement my_account; @FindBy(how= How.ID, using = "link-to-login") WebElement login_link; @FindBy(how= How.LINK_TEXT, using = "LOGOUT") WebElement logout; public void clickOnLoginLink() { login_link.click();} public String getMyAccountText() { return my_account.getText();} public void clickLogOut() { logout.click(); } } # Separate out Tests , Objects , and Implementation Flows Steps public String InvalidLogin(String userName, String password) { HomePage homePage = PageFactory.initElements(DriverManager.driver, HomePage.class); homePage.clickOnLoginLink(); LoginPage loginPage = PageFactory.initElements(DriverManager.driver, LoginPage.class); loginPage.enterUsername(userName); loginPage.enterPassword(password);
  4. 4. XtremeTesting ThoughtWorks loginPage.clickSubmit(); return loginPage.getInvalidLoginText();} Test @Test public void verifyValidLogintoSpree() { LoginSteps loginSteps = new LoginSteps(); String expected_message = loginSteps.Login("xt@xt.xom", "xtxtxt"); Assert.assertEquals(expected_message, "MY ACCOUNT"); } # Parameterize Tests Add it to xml <parameter name="userName" value="xt@xt.xom"/> <parameter name="password" value="xtxtxt" /> Add it to tests @Test @Parameters({"userName", "password"}) public void verifyValidLogintoSpree(String userName, String password) # Data Providers @DataProvider(name = "login") public static Object[][] loginData() { return new Object[][] {{"xt@xt.xom", "xtxtxt"}, {"xt@xt.xom", "xtxtxt"}};} @Test (dataProvider = "login") public void verifyValidLogintoSpreeWithDataProvider(String userName, String password)

×