WebDriverWait无法按预期工作

WebDriverWait无法按预期工作,第1张

WebDriverWait无法按预期工作

一旦您等待该元素并在尝试调用

click()
方法而不是使用
presence_of_element_located()
method时继续前进,则需要使用
element_to_be_clickable()


以下方法:

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

更新资料

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

present_of_element_located

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 locatedDescription : 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

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 visibleDescription : 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

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.


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5169521.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-18
下一篇 2022-11-18

发表评论

登录后才能评论

评论列表(0条)

保存