一旦您等待该元素并在尝试调用
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_locatedpresent_of_element_located(locator)的定义如下:
visible_of_element_locatedclass 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(locator)定义如下:
element_to_be_clickableclass 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(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.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)