本文整理汇总了Python中selenium.webdriver.support.wait.WebDriverWait.accept方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.accept方法的具体用法?Python WebDriverWait.accept怎么用?Python WebDriverWait.accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.wait.WebDriverWait
的用法示例。
在下文中一共展示了WebDriverWait.accept方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_compare_products_removal_alert
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import accept [as 别名]
def test_compare_products_removal_alert(self):
# get the search textbox
search_field = self.driver.find_element_by_name("q")
search_field.clear()
# enter search keyword and submit
search_field.send_keys("phones")
search_field.submit()
# click the Add to compare link
self.driver.\
find_element_by_link_text("Add to Compare").click()
# click on Remove this item link, this will display # an alert to the user
self.driver.find_element_by_link_text("Clear All").click()
# switch to the alert
#alert = self.driver.switch_to_alert()
alert = WebDriverWait(self.driver,10).until(expected_conditions.alert_is_present())
# get the text from alert
alert_text = alert.text
# check alert text
self.assertEqual("Are you sure you would like to remove all products from your comparison?", alert_text)
# click on Ok button
alert.accept()