Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 有时找不到元素_Python_Python 2.7_Selenium_Selenium Webdriver_Selenium Chromedriver - Fatal编程技术网

Python 有时找不到元素

Python 有时找不到元素,python,python-2.7,selenium,selenium-webdriver,selenium-chromedriver,Python,Python 2.7,Selenium,Selenium Webdriver,Selenium Chromedriver,我有一个无序的列表后,一个按钮点击,我想得到有多少个超链接与分页类 有时我得到0,但有一个ul的类=分页。我用时间睡觉,它工作得很好。但我想让它更有活力。 有人能帮我用WebDriverWait行代码来代替那段时间吗?sleep?让WebDriverWait和元素可以点击 导入以下库 from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_con

我有一个无序的列表后,一个按钮点击,我想得到有多少个超链接与分页类

有时我得到0,但有一个ul的类=分页。我用时间睡觉,它工作得很好。但我想让它更有活力。 有人能帮我用WebDriverWait行代码来代替那段时间吗?sleep?

让WebDriverWait和元素可以点击

导入以下库

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


这回答了你的问题吗?我现在正在检查它是不可点击的。我需要等待,直到在网页WebDriverWaitDriver上找到该元素,20.untelec.presence\u of_element\u locatedBy.CSS\u SELECTOR,'ul.paginated'我正在使用此代码检查line@PaulVio:检查编辑的答案。如果有帮助。
 element = driver.find_elements_by_class_name('paginated')
 print(len(element))
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'ul.paginated'))).click()
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
print(len(WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, 'ul.paginated')))))