简体   繁体   English

ElementNotInteractableException:消息:元素不可交互

[英]ElementNotInteractableException: Message: element not interactable

I have yet another question regarding ElementNotInteractableException: Message: element not interactable我还有另一个关于ElementNotInteractableException: Message: element not interactable

I'm taking my first steps into python (trying to start QA automation route (Been a manual QA for years now)).我正在向 python 迈出第一步(尝试启动 QA 自动化路线(多年来一直是手动 QA))。 So I tried looking this up in the web but no answer I found worked for me.因此,我尝试在 web 中查找此内容,但没有找到适合我的答案。

Description (Skip if you want): I'm trying to run a simple code to ask for an MTG card, then go look for its price (at a later iteration of this script, you will be able to pick and choose from a list of pages to query)描述(如果你想跳过):我正在尝试运行一个简单的代码来询问 MTG 卡,然后 go 查找它的价格(在此脚本的稍后迭代中,您将能够从列表中挑选要查询的页面数)

Code:代码:

from selenium import webdriver
from time import sleep
from xpaths import *

card = input('What card are you looking for?')
driver = webdriver.Chrome()
driver.get(url)
searchBox = driver.find_element_by_xpath(searchBox)
sleep(1)
searchBox.send_keys(card)

No matter what I try (slee, wait, clicking the element) I always get the same response selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable无论我尝试什么(睡觉,等待,单击元素),我总是得到相同的响应selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

(BTW, Im trying to search for a card in starcitygames.com) (顺便说一句,我正在尝试在 starcitygames.com 中搜索卡片)

Any help will be appreciated, keep in mind this is my first real coding attempt.任何帮助将不胜感激,请记住这是我第一次真正的编码尝试。

Edit: I'm finding the element searchBox by its xpath = searchBox = '//*[@id=\"search_query\"]'编辑:我通过它的xpath = searchBox = '//*[@id=\"search_query\"]'找到元素searchBox

Thanks!谢谢!

ElementNotInteractableException occurs when an element is found, but you can't be interacted with. ElementNotInteractableException 在找到元素时发生,但您无法与之交互。 This could happen due to various reasons like element being not visible or displayed, element is off screen or element is behind another element or hidden.这可能由于各种原因而发生,例如元素不可见或不显示、元素不在屏幕上或元素在另一个元素后面或隐藏。 Try some of the actions below.尝试以下一些操作。

This looks like it's a dynamically generated element, so interact directly with DOM using the second method.这看起来像是一个动态生成的元素,所以使用第二种方法直接与 DOM 交互。 Commands below are in Java syntax, you can research and apply the same relevancy to python.以下命令采用 Java 语法,您可以研究并将相同的相关性应用于 python。

  1. Wait until an element is visible / clickable等到元素可见/可点击
WebDriverWait wait = new WebDriverWait(driver, timeout);
wait.until(ExpectedConditions.visibilityOf(element)); 
wait.until(ExpectedConditions.elementToBeClickable(element));
  1. Use JS Executor to interact directly with the DOM使用 JS Executor 直接与 DOM 交互
JavascriptExecutor javascript = (JavascriptExecutor) driver;
javascript.executeScript("var element = document.querySelector('locator'); element.value = 'whatever';")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python selenium ElementNotInteractableException:消息:元素不可交互 - Python selenium ElementNotInteractableException: Message: element not interactable Python 中的 Selenium:ElementNotInteractableException:消息:元素不可交互 - Selenium in Python: ElementNotInteractableException: Message: element not interactable ElementNotInteractableException:元素在 Selenium 中不可交互 - ElementNotInteractableException: element not interactable in Selenium ElementNotInteractableException:元素不可交互 - ElementNotInteractableException: element not interactable Selenium.common.exceptions.ElementNotInteractableException:消息:元素在离子框架中不可交互 - Selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable in ionic framework 发现 selenium.common.exceptions.ElementNotInteractableException:消息:元素不可交互 - Found selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable 错误是“selenium.common.exceptions.ElementNotInteractableException:消息:元素不可交互” - error is “selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable” 网页抓取:selenium.common.exceptions.ElementNotInteractableException:消息:元素不可交互 - Webscraping: selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable 为什么该元素不能使用 selenium 进行交互? selenium.common.exceptions.ElementNotInteractableException:消息:元素不可交互 - Why is the element not interactable using selenium? selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable ElementNotInteractableException:消息:元素不是元素不可交互错误使用 Selenium 和 Python 将文本发送到 Email 字段 - ElementNotInteractableException: Message: element not element not interactable error sending text to Email field using Selenium and Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM