本文整理汇总了Python中selenium.webdriver.support.wait.WebDriverWait.is_selected方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.is_selected方法的具体用法?Python WebDriverWait.is_selected怎么用?Python WebDriverWait.is_selected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.wait.WebDriverWait
的用法示例。
在下文中一共展示了WebDriverWait.is_selected方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_checked
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import is_selected [as 别名]
def is_checked(self, compared_to_average):
checkbox = WebDriverWait(self.driver, 30, 0.5).until(
lambda d: d.find_elements_by_css_selector(self.COMPARED_TO_AVERAGE)[compared_to_average]
)
if checkbox.is_selected():
return True
return False
示例2: is_business_node_checked
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import is_selected [as 别名]
def is_business_node_checked(self, business_node_number):
checkbox = WebDriverWait(self.driver, 30, 0.5).until(
lambda d: d.find_elements_by_css_selector(self.BUSINESS_NODES_CHECKBOXES)[business_node_number + 1]
)
if checkbox.is_selected():
return True
return False
示例3: assertChecked
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import is_selected [as 别名]
def assertChecked(self, locator, rule, timeout=-1, msg=None):
"""assert a checkbox, radiobutton or option is checked
:param locator: the engine to process the rule
:type locator: selenium.webdriver.common.by.By
:param rule: the rule the element must match
:type rule: str
:param timeout: Number of second that we will poll the DOM. Once this is over, a TimeoutException is raised \
if timeout is less than 0, no wait is processed
:type timeout: int
"""
try:
if timeout > 0:
element = WebDriverWait(self.driver, timeout).until(
EC.presence_of_element_located((locator, rule))
)
else:
element = self.driver.find_element(locator, rule)
except (NoSuchElementException, TimeoutException) as e:
raise self.failureException(str(e))
self.assertTrue(element.is_selected(), msg=msg)