Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/
I am expecting here that after every method @AfterMethod annotation should be executed. However it doesnt seems working.
public class Q1 { public static WebDriver driver; @BeforeMethod public void launchBrowser() { System.setProperty("webdriver.gecko.driver", "C://geckodriver.exe"); driver = new FirefoxDriver(); } @Test(priority = 1) public void checkTitle() { driver.get("http://www.google.com"); Assert.assertEquals("Google", driver.getTitle()); } @Test(priority = 2) public void verifyTitle() { driver.get("https://in.yahoo.com"); Assert.assertEquals("Yahoo", driver.getTitle()); } @Test(priority = 3) public void validateTitle() { driver.get("http://www.google.ca"); Assert.assertEquals("Google", driver.getTitle()); } @AfterMethod public void closeBrowser() { driver.close(); }}
public class Q1 {
public static WebDriver driver;
@BeforeMethod public void launchBrowser() { System.setProperty("webdriver.gecko.driver", "C://geckodriver.exe"); driver = new FirefoxDriver(); }
@Test(priority = 1) public void checkTitle() { driver.get("http://www.google.com"); Assert.assertEquals("Google", driver.getTitle()); }
@Test(priority = 2) public void verifyTitle() { driver.get("https://in.yahoo.com"); Assert.assertEquals("Yahoo", driver.getTitle()); }
@Test(priority = 3) public void validateTitle() { driver.get("http://www.google.ca"); Assert.assertEquals("Google", driver.getTitle()); }
@AfterMethod public void closeBrowser() { driver.close(); }}
Help would be appreciated.
This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!
1.4k questions
1.6k answers
866 comments
1.9k users