mercredi 21 août 2019

Login process : Not read my else statement in selenium

My if else inside my for loop.This if else to verify the data from the excel to login. i try to bug, it shows that it skip else statement.Getting error no such element " email". The error at line driver.findElement(By.name("email")).clear();.

for(int i=1; i<=5; i++) { 
                    cell = sheet.getRow(i).getCell(0);
                    WebElement email = driver.findElement(By.name("email"));
                    email.sendKeys(cell.getStringCellValue());                      

                    cell = sheet.getRow(i).getCell(1);
                    WebElement password = driver.findElement (By.name("password"));
                    password.sendKeys(cell.getStringCellValue());


                    driver.findElement(By.xpath("/html/body/div/div/div[2]/div/div/form/div[4]")).click();
                    Thread.sleep(8000);

                    try {

                        if(driver.findElement(By.className("description")).isDisplayed()) {

                            driver.findElement(By.id("btn-skip")).click();

                            }
                            else{
                                    System.out.println("invalid");
                                    //driver.findElement(By.id("btn-skip")).click();
                            }

                    }
                    catch(NoSuchElementException e) {

                    }

                    driver.findElement(By.name("email")).clear();

                    System.out.print(sheet.getRow(i).getCell(0) + " ");
                    System.out.println(sheet.getRow(i).getCell(1));

                    }

Aucun commentaire:

Enregistrer un commentaire