vendredi 20 février 2015

How to get text out of div class tag in selenium webdriver?


<div class="error-text">invalid login or password.</div>


HOw do I retrieve the actual text "invalid login or password"? I m running the test on testNG. Here is my test java code:



WebElement wrong_message = firefox.findElement(By.xpath("//*[@id=\"login-form\"]/div[3]"));
System.out.println("message is here:" + wrong_message.getText().toString());
Assert.assertNotNull(wrong_message);


But the output of testrun has empty string instead of "invalid login or password".


Aucun commentaire:

Enregistrer un commentaire