社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

selenium中使用python的ElementNotInteractiableException

Eeplo • 3 年前 • 1223 次点击  

我试图学习selenium,但我偶然发现了一个似乎无法修复的错误:ElementNotInteractiableException(代码给出了timeoutexception)。 我读过各种stackoverflow帖子,尝试过答案,但都不管用。 我只是想在Youtube的搜索栏里输入几个词。 不管怎样,代码是这样的。

import undetected_chromedriver.v2 as uc
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.common.keys import Keys

options = uc.ChromeOptions()
options.binary_location = "C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"
options.add_argument("--user-data-dir=c:\\temp\\testprofile2")
driver = uc.Chrome(options=options)
driver.get("https://www.youtube.com/")


def enter_search_term(driver):
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="search"]'))).send_keys("test")
    time.sleep(5)
    driver.quit()

enter_search_term(driver)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/129223
 
1223 次点击  
文章 [ 2 ]  |  最新文章 3 年前