gpt4 book ai didi

python-3.x - clear()不会使用selenium和python和firefox清除文本框

转载 作者:行者123 更新时间:2023-12-01 11:17:16 24 4
gpt4 key购买 nike

clear()在这种情况下不起作用。我要追加后追加。searchForMovie.clear()无法正常工作...我也尝试发送
CTRL + 'a',然后是DELETE。同样,我得到的只是附件...

 for movie in allMissing:

time.sleep (10)

searchForMovie = WebDriverWait (driver, 10).until \
(EC.presence_of_element_located ((By.CSS_SELECTOR, "#search-text")))

searchForMovie.send_keys (movie)

# click
enter = WebDriverWait (driver, 10).until \
(EC.presence_of_element_located ((By.CSS_SELECTOR, "#search-submit")))

driver.execute_script ("arguments[0].click()", enter)


# clear the search text box
searchForMovie = WebDriverWait (driver, 10).until \
(EC.presence_of_element_located ((By.CSS_SELECTOR, "#search-text")))

searchForMovie.clear()

最佳答案

要清除文本框,您需要使用expected_conditions设置为element_to_be_clickable来诱导WebDriverWait,然后在WebElement上调用click(),然后如下所示调用clear():

# clear the search text box
searchForMovie = WebDriverWait (driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#search-text")))
searchForMovie.click()
searchForMovie.clear()

关于python-3.x - clear()不会使用selenium和python和firefox清除文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49151508/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com