您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

WebDriverWait无法按预期工作

WebDriverWait无法按预期工作

一旦您等待该元素并在尝试调用click()方法而不是使用presence_of_element_located()method时继续前进,则需要使用 以下方法

try:
    myElem = webdriverwait(self.browser, delay).until(EC.element_to_be_clickable((By.XPATH , xpath)))

根据您在评论中的反问题,以下是这三种方法的详细信息:

present_of_element_located(locator)的定义如下:

class selenium.webdriver.support.expected_conditions.presence_of_element_located(locator)

Parameter : locator - used to find the element returns the WebElement once it is located

Description : An expectation for checking that an element is present on the DOM of a page. This does not necessarily mean that the element is visible or interactable (i.e. clickable).

visible_of_element_located(locator)定义如下:

class selenium.webdriver.support.expected_conditions.visibility_of_element_located(locator)

Parameter : locator -  used to find the element returns the WebElement once it is located and visible

Description : An expectation for checking that an element is present on the DOM of a page and visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0.

element_to_be_clickable(locator)定义如下:

class selenium.webdriver.support.expected_conditions.element_to_be_clickable(locator)

Parameter : locator - used to find the element returns the WebElement once it is visible, enabled and interactable (i.e. clickable).

Description : An Expectation for checking an element is visible, enabled and interactable such that you can click it.
其他 2022/1/1 18:14:03 有571人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶