samedi 17 décembre 2016

How to close multiple windows working with Test NG framework

Suppose i have 5 test case and 2nd and 3rd one fails so after statement Assert.assertEquals("http://ift.tt/1892vb9",driver.getCurrentUrl());

driver.close will not work. How to close all the windows failed once too

Trying with window handle too but not getting satisfactory results.

public static WebDriver driver;

@Test(dataProvider="inputdata")
public void login(String val1,String val2){
    System.setProperty("webdriver.chrome.driver","C:/Users/rakesh/Desktop/chromedriver.exe");
    driver =new ChromeDriver();
    driver.get("http://ift.tt/2cvumqF");
    driver.findElement(By.name("uid")).sendKeys(val1);
    driver.findElement(By.name("password")).sendKeys(val2);
    driver.findElement(By.name("btnLogin")).click();
    Assert.assertEquals("http://ift.tt/1892vb9",driver.getCurrentUrl());
    driver.close();


}
@DataProvider(name="inputdata")
public Object[][] readExcel() throws BiffException, IOException {
    File f= new File("C:/Users/rakesh/Desktop/selenium/input data/loginTable.xls");
    Workbook w =Workbook.getWorkbook(f);
    Sheet s= w.getSheet("Sheet1");
    int rows=s.getRows();
    int columns=s.getColumns();
    //System.out.println(rows);
    //System.out.println(columns);

    String inputData [][] = new String[rows][columns];
    for(int i=0;i<rows;i++){
        for(int j=0;j<columns;j++){
            Cell c=s.getCell(j,i);
            inputData[i][j]=c.getContents();
            //System.out.println(inputData[i][j]);
        }
    }
    return inputData;


}

Aucun commentaire:

Enregistrer un commentaire