问题
I recently updated my chrome version to latest i.e. 79.0.3945.130 (Official Build) (64-bit)
and downloaded compatible chromedriver from here
I've started facing this error. While debugging in detail i found that the Select
class causing the issue. wherever I'm selecting a dropdown in my code I'm getting this issue.
The HTML of dropdown looks like below snippet:
<div class="rd-input--wrapper" id="178">
<label for="attribute178">Flavour</label>
<select name="super_attribute[178]" data-selector="super_attribute[178]" data-validate="{required:true}" id="attribute178" class="super-attribute-select">
<option value="">Select</option>
<option value="27">Chocolate</option>
<option value="28">Strawberry</option>
</select>
</div>
And dropdown on Webpage:
I'm using below code to select a value
Select s = new Select(getDriver().findElement(By.id("attribute178")));
s.selectByIndex(1);
Error stacktrace
Javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite. (Session info: chrome=79.0.3945.130) Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:24:21.231Z' System info: host: 'ispl_723.test.com', ip: 'fe80:0:0:0:419:64fe:5dea:dae5%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_191' Driver info: com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 79.0.3945.130, chrome: {chromedriverVersion: 79.0.3945.36 (3582db32b3389..., userDataDir: /var/folders/qf/x6bn9cgj1rx...}, goog:chromeOptions: {debuggerAddress: localhost:61452}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Earlier I was using Chrome 75 and everything was working as expected. Has anyone faced this issue? Already posted question related to this error on SO is not helpful.
回答1:
This error message...
Javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite
...implies that the WebDriver instance was unable to find the element for one or the other reasons:
- The element havn't loaded properly when you tried to interact with it.
- Element is within an
<iframe>
/<frame>
- The style attribute of the element contains
display: none;
- Element is within an shadow DOM
The relevant HTML would have been helpful to analyze the issue in a better way. However, you need to take care of a couple of things as follows:
- The
id
attribute of the<select>
tag is attribute178 which is clearly dynamic. So you need to construct a dynamic Locator Strategy As the
id
attribute of the<select>
tag is dynamic, you need to induce WebDriverWait for theelement_to_be_clickable()
and you can use either of the following Locator Strategies:cssSelector
:Select s = new Select(new WebDriverWait(getDriver(), 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("select.super-attribute-select[id^='attribute']")))); s.selectByIndex(1);
xpath
:Select s = new Select(new WebDriverWait(getDriver(), 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//select[@class='super-attribute-select' and starts-with(@id, 'attribute')]")))); s.selectByIndex(1);
回答2:
In my case i was using new Actions(driver).moveToElement(element).perform();
in Command Listener before each command so it move the focus on element which being executed.
This line causing the error mentioned in question. After commenting this its working fine.
来源:https://stackoverflow.com/questions/63157343/message-javascript-error-failed-to-execute-elementsfrompoint-on-document