clear()不会使用selenium和python和firefox清除文本框 [英] clear() does not clear the textbox with selenium and python and firefox

查看:371
本文介绍了clear()不会使用selenium和python和firefox清除文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

clear() does not work in this case. I am getting append after append.
searchForMovie.clear() is not working... I have also tried to send
CTRL + 'a', and then the DELETE. Again all I got are just appends...

 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 ,然后按如下所示调用clear():

To clear the textbox you need to induce WebDriverWait with expected_conditions set to element_to_be_clickable, next invoke click() on the WebElement and then invoke clear() as follows :

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

这篇关于clear()不会使用selenium和python和firefox清除文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆