简体   繁体   English

Selenium ElementNotInteractableError:元素不可交互

[英]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.

相关问题 硒元素不可相互作用 - selenium element not interactable 带有硒的 Powershell:错误:元素不可交互 - Powershell with Selenium: Error: element not interactable 文本框 selenium javascript 类型的输入元素的元素不可交互错误 - Element not interactable error for input element of type textbox selenium javascript 如何使用 Javascript 等到元素在 Selenium 中可交互 - How to wait until element is interactable in Selenium using Javascript selenium.common.exceptions.ElementNotInteractableException:消息:使用Selenium和Python插入值时元素不可交互 - selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable while inserting value using Selenium and Python 量角器:元素当前不可交互,并且可能无法操纵 - Protractor: Element is not currently interactable and may not be manipulated 元素显示在 chromedriver DOM 中,但 Protractor 显示失败:元素不可交互 - Element displays in chromedriver DOM, but Protractor says Failed: element not interactable 如何单击与硒和python不可交互的下拉菜单,然后选择一个选项? - How to click not interactable dropdown with selenium and python and select one option? 无效元素状态:元素当前不可交互且不可操作 - invalid element state: Element is not currently interactable and may not be manipulated 堆栈:WebDriverError:元素不可交互 - Protractor e2e - Stack: WebDriverError: element not interactable - Protractor e2e
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM