[英]Selenium ElementNotInteractableError: element not interactable
I started to learn Selenium this morning lol but i'm stuck trying to click on a element like this:我今天早上开始学习 Selenium 哈哈,但我一直在尝试点击这样的元素:
<a rel="nofollow" style="" href="javascript:void(0);" time="" itemid="1523208" data-has-req="0" class="button okletsdothis nonsubscriber dl button-green" title="Download">
<span class="icon-download" time="" itemid="1523208"></span>
Download
</a>
In the console I'm getting this error在控制台中我收到此错误
ElementNotInteractableError: element not interactable ElementNotInteractableError:元素不可交互
This is the code where I wait until the element is located and then try to perform the click action这是我等到找到元素然后尝试执行点击操作的代码
let downloadButton = await driver.wait(
until.elementLocated(
By.xpath(
'(//a[@class="button okletsdothis nonsubscriber dl button-green"])'
)
),
100000,
"Timed out after 30 seconds",
5000
);
await downloadButton.click();
If I change the xpath and click on a element like this如果我更改 xpath 并单击这样的元素
By.xpath('(//div[@class="download-button ide"])')
it works fine, but in the case before i can't make it work.它工作正常,但在我无法使其工作之前的情况下。 Please help.请帮忙。
To click on the element with text as Download you can use the following Locator Strategies :要单击带有文本作为下载的元素,您可以使用以下定位器策略:
let downloadButton = await driver.wait(
until.elementLocated(
By.xpath(
'(//a[@class="button okletsdothis nonsubscriber dl button-green" and @title="Download"])'
)
),
100000,
"Timed out after 30 seconds",
5000
);
await downloadButton.click();
Or或者
let downloadButton = await driver.wait(
until.elementLocated(
By.xpath(
'(//a[@class="button okletsdothis nonsubscriber dl button-green" and @title="Download"]/span[@class="icon-download"])'
)
),
100000,
"Timed out after 30 seconds",
5000
);
await downloadButton.click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.