Bug 216479
| Summary: | SafariDriver throws NoSuchElementException attempting to find child of element reference that's gone stale | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Scott Babcock <scoba> |
| Component: | WebDriver | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED MOVED | ||
| Severity: | Normal | CC: | bburg, bfulgham, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Scott Babcock
## 🐛 Bug Report
SCENARIO: Invoke the `findElement` method of an element reference that's gone stale
EXPECT: StaleElementReferenceException
ACTUAL: NoSuchElementException
## To Reproduce
Detailed steps to reproduce the behavior:
* Acquire a reference to an element that has children
* Refresh the browser session
* Search for a child of the element reference
With the Java code below:
* [getTagName] throws `StaleElementReferenceException`
* [findElement] throws `NoSuchElementException`
## Expected behavior
This should produce `StaleElementReferenceException`
## Actual behavior
**SafariDriver** throws `NoSuchElementException`
## Test script or set of commands reproducing this issue
```java
package com.nordstrom.automation.selenium.model;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.safari.SafariDriver;
public class SafariStale {
private WebDriver driver;
@Before
public void before() {
driver = new SafariDriver();
}
@Test
public void testStale() {
driver.get("https://www.w3schools.com/html/html_tables.asp");
WebElement table = driver.findElement(By.cssSelector("table#customers"));
table.getTagName();
table.findElement(By.cssSelector("tr"));
driver.navigate().refresh();
try {
table.getTagName();
} catch (WebDriverException e) {
System.out.printf("[getTagName] throws %s\n", e.getClass().getSimpleName());
}
try {
table.findElement(By.cssSelector("tr"));
} catch (WebDriverException e) {
System.out.printf("[findElement] throws %s\n", e.getClass().getSimpleName());
}
}
@After
public void after() {
driver.quit();
}
}
```
## Environment
OS: MacOS 10.15.4
Browser: Safari
Browser version: 13.1 (15609.1.20.111.8)
Browser Driver version: Included with Safari 13.1 (15609.1.20.111.8)
Language Bindings version: 3.141.59
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Scott Babcock
Migrated from https://github.com/SeleniumHQ/selenium/issues/8376
In my original code, I called each method before and after the `refresh`. Prior to refreshing the session, `getTagName` returns "table" and `findElement` returns the child "tr" element. I revised the repro code to include these happy-path method calls.
Other drivers I've tried (ChromeDriver, FirefoxDriver, HtmlUnitDriver, GhostDriver) all exhibit the expected behavior. This is definitely a bug in SafariDriver, or perhaps in Safari itself.
Radar WebKit Bug Importer
<rdar://problem/69319181>
Blaze Burg
Thanks for the very clear report. I'll take a look at this.
Brent Fulgham
The fix for this issue was needed outside the WebKit project, therefore this is being resolved as 'Moved'.
This should now be fixed in current macOS 12.3 betas.