Reputation: 69
@BeforeTest
public void beforeTest() {
WebDriver driver;
System.setProperty("webdriver.chrome.driver","E:\\chromedriver.exe");
//System.setProperty("webdriver.chrome.driver","E:\\geckodriver.exe");
driver = new ChromeDriver();
String baseurl = "http://demosite.center/wordpress/wp-login.php";
driver.get(baseurl);
driver.manage().window().maximize();
}
@Test
public void VerifyLogin() {
LoginClass login = new LoginClass(driver);
login.Username();
login.Password();
login.Submit();
}
@AfterTest
public void afterTest() {
driver.close();
}
}
Only @Before test is running, @Test and @After Test is not running in selenium
Upvotes: 0
Views: 525
Reputation: 5347
This may be due to the local variable driver in your before Test method. I guess, you have one more instance variable in the class with name as driver. You have assigned the local variable driver, not with instance variable.
May be you need to comment the local variable driver like,
@BeforeTest
public void beforeTest() {
//WebDriver driver;
System.setProperty("webdriver.chrome.driver","E:\\chromedriver.exe");
//System.setProperty("webdriver.chrome.driver","E:\\geckodriver.exe");
driver = new ChromeDriver();
String baseurl = "http://demosite.center/wordpress/wp-login.php";
driver.get(baseurl);
driver.manage().window().maximize();
}
Upvotes: 1