lundi 26 juin 2017

It gives error as unable to find element when script is excuted with TestNG

It gives error as unable to find element when below script is excuted with TestNG. Same code is executed successfully when run without TestNG

@Test(priority=0)
  public void verifyHomepageTitle() {

      System.out.println("Launching firefox browser"); 
      System.setProperty("webdriver.gecko.driver", driverPath);
      driver = new FirefoxDriver();
      driver.get(baseUrl);
      String expectedTitle = "Login";
      String actualTitle = driver.getTitle();
      Assert.assertEquals(actualTitle, expectedTitle);
     // driver.close();
  }



 @Test(priority=1)
  public void login(){

        driver.findElement(By.id("LoginForm_email")).sendKeys("bits.qa1@gmail.com");
        driver.findElement(By.id("LoginForm_password")).sendKeys("benchmark");
        driver.findElement(By.id("LoginForm_rememberMe")).click();
        driver.findElement(By.xpath("//button[contains(.,'Sign in')]")).click();
  }

@Test(priority=2)
  public void updateEntity() throws InterruptedException
  {

        String innerText= driver.findElement(By.xpath("//table/tbody/tr/td")).getText();
        System.out.println(innerText);
        //driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
        Thread.sleep(10000);
        driver.findElement(By.xpath("//table/tbody/tr/td")).click();
  }

Aucun commentaire:

Enregistrer un commentaire