"Can't access dead object" in geckodriver
It looks like the frame is reloaded with a new reference while you are waiting for the element some_id
.
I would classify this issue as a bug since the error returned by the driver is not defined by the WebDriver
protocol.
Your best chance to make it work is probably to implement a custom waiter to locate the frame/element and skip unhandled exceptions:
WebElement elem = waiter.Until(elementToBeClickableInFrame(By.id("contentframe"),
By.id("some_id")));
public static ExpectedCondition<WebElement> elementToBeClickableInFrame(final By locatorFrame, final By locator) {
return new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
try {
driver.switchTo().defaultContent();
driver.switchTo().frame(driver.findElement(locatorFrame));
WebElement elem = driver.findElement(locator);
return elem.isDisplayed() && elem.isEnabled() ? elem : null;
} catch (Exception e) {
return null;
}
}
@Override
public String toString() {
return "element located by: " + locator + " in " + locatorFrame;
}
};
}
Not sure if this will help you but when I ran into this error message, I was able to get past it by having:
driver.switchTo().defaultContent();
driver.switchTo().frame(0);
between each interaction with an element in the iframe.
Example:
driver.switchTo().frame(0);
myPage.selectElement(getCycleSummary());
driver.switchTo().defaultContent();
driver.switchTo().frame(0);
myPage.selectDisplayedElement(this.getCycleBtn());
Without the driver switches I would receive the dead object error.