selenium.common.异常.ElementNotVisibleException:消息:元素无法使用Selenium进行交互

2024-09-29 20:23:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在寻找做一个程序的乐趣,但我有一些问题硒和我 需要帮助。。。 这是程序(我删除了webdriver的目录,因为文件夹名中包含了其他人的名字)

from selenium import webdriver
import webbrowser
import time


def Pass_send_():
    driver=webdriver.Chrome()
    driver.get('chrome://flags/#password_export-enable')


    ricerca=driver.find_element_by_id("search")
    ricerca.send_keys('password export')
    scorritore=driver.find_element_by_class_name('experiment-select')
    scorritore.click()



Pass_send_()

所以它的目的很简单,它应该打开一个窗口,输入一个文本,然后单击一个按钮。一切正常,但点击无效,错误如下:

^{pr2}$

所以我不是专家,但它说:元素不可交换?这是什么意思?我怎样才能修复它?我真的很感谢你的回复。。。在


Tags: import程序目录文件夹sendbydriverexport
1条回答
网友
1楼 · 发布于 2024-09-29 20:23:41

要将字符序列发送到网页^{中的搜索框,您需要诱导WebDriverWait,您可以使用以下解决方案:

  • 代码块:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
    options = Options()
    options.add_argument('start-maximized')
    options.add_argument('disable-infobars')
    options.add_argument(' disable-extensions')
    driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get('chrome://flags/#password_export-enable')
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#search"))).send_keys("password export")
    
  • 浏览器快照:

chrome_password_export

相关问题 更多 >

    热门问题