wkeeling / selenium-wire

Extends Selenium's Python bindings to give you the ability to inspect requests made by the browser.
MIT License
1.9k stars 254 forks source link

Error finding page element using selenium wire #482

Open JLX120 opened 2 years ago

JLX120 commented 2 years ago

Hello, when I wanted to use selenium wire to find page elements, I encountered a problem. I don't know why? When I use find_ When elements looks for page elements, it returns the results I found, but when I send the data to be filled in, it prompts me "element not interactive", and sometimes it does find and send the data I want to fill in. Why can't I find it, so I want to ask you? image image

wkeeling commented 2 years ago

If you switch to using selenium directly (no selenium wire), do you still get the same problem?

JLX120 commented 2 years ago

如果你直接改用selenium(没有selenium 线),你还会遇到同样的问题吗?

This will not happen when using selenium directly, but because the website I want to visit must use a dynamic proxy, I use selenium wire to configure dynamic proxy access and then find elements

wkeeling commented 2 years ago

I don't know why selenium wire would cause that to happen, although it might the indirect result of latency introduced by request capture.

It seems as though the div element is not ready at the point you try to send data to it. Have you tried explicitly waiting until the element is visible?

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

div = WebDriverWait(driver, 20).until(
    EC.visibility_of_element_located((By.XPATH, '//input[@class="quantumWizTextinputPaperinputInput exportInput"]'
)))
JLX120 commented 2 years ago

我不知道为什么硒线会导致这种情况发生,尽管它_可能_是请求捕获引入的延迟的间接结果。

div在您尝试向其发送数据时,该元素似乎尚未准备好。您是否尝试过显式等待元素可见?

来自 硒。网络驱动程序。常见的。由 进口 到
来自 硒。网络驱动程序。支持。ui 从selenium导入 WebDriverWait
。网络驱动程序。支持导入expected_conditions作为EC div = WebDriverWait ( driver , 20 )。直到(
     EC。visibility_of_element_located((通过。XPATH,     

  '//input[@class="quantumWizTextinputPaperinputInput exportInput"]' 
)))

I tried to wait invisibly, but it still has the same error prompt "element not interactive". I don't know why it sometimes sends data and sometimes doesn't send data? image

JLX120 commented 2 years ago

When I use display wait, it does find the element I want to find, but when I send data, it mostly fails and rarely succeeds

wkeeling commented 2 years ago

@JLX120 did you manage to resolve this in the end?