Need help with @AfterTest | Selenium Forum
M
Posted on 22/08/2015
Hi Ashish,

why is my code not quitting the browser. Could you please tell me the mistake I am making.

I am looking for a simple test case using data driven creating 2 accounts with different username and password. Could you please tell me which module should I check. I dont want to create the entire framework.

********************************************************

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.Test;


public class CreateAccount {

WebDriver driver;

@Test
public void account(){

WebDriver driver = new FirefoxDriver();
driver.get("https://app.recurly.com/login");

//Login to the user with the email and the password and click the login button
driver.findElement(By.xpath("//*[@id='user_email']")).sendKeys("test@gmail.com");
driver.findElement(By.xpath("//*[@id='user_password']")).sendKeys("Test1234");
driver.findElement(By.xpath("html/body/div/div/form/div[2]/input")).click();

}
@AfterTest
public void close() throws InterruptedException{
driver.quit();
}





}

M
Replied on 23/08/2015

WebDriver driver = new FirefoxDriver();
in @ test should be
driver = new FirefoxDriver();



Dont create new driver object. It will hide global one

For a simple parameterization example.. look at video 17 exrcises