forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Dj edited this page Sep 21, 2015
·
4 revisions
A NoSuchElementException appears when the element you are attempting to find does not satisfy your selector strategy.
Consider the following:
<a id="my-link" href="...">My Link</a>// works
driver.findElement(By.id("my-link"));
driver.findElement(By.linkText("My Link"));
// throws org.openqa.selenium.NoSuchElementException
driver.findElement(By.linkText("My link")); // lowercase "L"A StaleReferenceException is thrown when an element that was identified previously has been mutated in the DOM and you attempted to interact with it after the mutation.
Consider the following:
<a id="my-link" onclick="this.href='new'" href="...">Link Text</a>@FindBy(id = "my-link")
WebElement link;
link.click(); // works
link.click(); // throws because element has been mutated