selenium - Can any one help me , my Test Ng annotations are not running .In the Below code my @before class only running but not other -
in below code trying automate gmail data driven frame work using testng , code @before annotation executing not other 2 .please healp me.
import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.firefox.firefoxdriver; import org.testng.annotations.test; import org.testng.annotations.beforetest; import org.testng.annotations.aftertest; public class logindata { webdriver driver; @test public void login() { driver.findelement(by.linktext("sign in")).click(); system.out.println("hello"); } @beforetest public void beforetest() throws exception { webdriver driver=new firefoxdriver(); driver.get("https://www.gmail.com/intl/en/mail/help/about.html"); thread.sleep(2000); } @aftertest public void ftertest() { driver.close(); } }
since have declared webdriver driver already; remove webdriver webdriver driver==new firefoxdriver();
i tried below , worked me.
import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.firefox.firefoxdriver; import org.testng.annotations.aftermethod; import org.testng.annotations.beforemethod; import org.testng.annotations.test; import org.testng.annotations.beforetest; import org.testng.annotations.aftertest; public class logindata1 { webdriver driver; @test public void login() { driver.findelement(by.linktext("sign in")).click(); system.out.println("hello"); } @beforetest public void beforetest() throws exception { driver=new firefoxdriver(); driver.get("https://www.gmail.com/intl/en/mail/help/about.html"); thread.sleep(2000); } @aftertest public void ftertest() { driver.close(); } }
accept if works or let me know if not work... thanks
Comments
Post a Comment