This error message...
org.openqa.selenium.WebDriverException: unknown error: failed to parse value of getElementRegion
...implies that the GetElementRegion()
method failed to parse the value.
Deep dive
This error is coming from element_util.cc:
Status GetElementRegion(
Session* session,
WebView* web_view,
const std::string& element_id,
WebRect* rect) {
Status status = CheckElement(element_id);
if (status.IsError())
return status;
base::ListValue args;
args.Append(CreateElement(element_id));
std::unique_ptr<base::Value> result;
status = web_view->CallFunction(
session->GetCurrentFrameId(), kGetElementRegionScript, args, &result);
if (status.IsError())
return status;
if (!ParseFromValue(result.get(), rect)) {
return Status(kUnknownError,
"failed to parse value of getElementRegion");
}
return Status(kOk);
}
Reasons and Solutions
There can be diverse reasons and solutions to this error as follows:
- Ensure the Locator Strategy for visibleElement identifies the element uniquely within the DOM Tree
Induce WebDriverWait for the elementToBeClickable()
before you invoke doubleClick()
as follows:
new Actions(driver).doubleClick(new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(visibleElement))).perform();
Add the build()
step:
new Actions(driver).doubleClick(new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(visibleElement))).build().perform();
Before you try to invoke doubleClick()
from Actions Class ensure that Selenium have the focus within the correct Frame i.e. either the Top Level View or an <iframe>
element.
Here you can find a relevant discussion on Ways to deal with #document under iframe
Here you can find a relevant discussion on How to automate shadow DOM elements using selenium?