Reputation: 27
i am trying to display the number 1 in my console, apparently it did not work, any advise please
This is my code apparently it didn't work.
String error1 = driver.findElement(By.xpath("//div[@class='label label-error']/span[@class='sidebar-label']")).getText();
the console error output
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@class='label label-error']/span[@class='sidebar-label']"}
Upvotes: 1
Views: 459
Reputation: 10061
Your Xpath is Wrong, Use one of these:
//div[@class="sidebar-label"]/span
//div[@class="sidebar-label"]/span[@class="label label-error"]
//*[@class="label label-error"]
Upvotes: 1