本文整理汇总了Python中selenium.webdriver.support.ui.WebDriverWait.is_displayed方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.is_displayed方法的具体用法?Python WebDriverWait.is_displayed怎么用?Python WebDriverWait.is_displayed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.ui.WebDriverWait
的用法示例。
在下文中一共展示了WebDriverWait.is_displayed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_logout_link_visible
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def test_logout_link_visible(self):
nav_logout = WebDriverWait(self.browser, 10).until(
expected_conditions.presence_of_element_located((By.ID, "nav_logout"))
)
self.assertFalse(nav_logout.is_displayed(), "The dropdown menu logout item must not be displayed yet!")
# Activate the dropdown menu and see if the logout link is visible.
dropdown_menu = self.browser.find_element_by_xpath("//*[@id=\"wrapper\"]/div[1]/div/div/div[2]/ul/li[7]/a")
WebDriverWait(self.browser, 3).until(
expected_conditions.visibility_of(dropdown_menu)
)
self.browser_activate_element(elem=dropdown_menu)
self.assertTrue(nav_logout.is_displayed(), "The dropdown menu logout item is not displayed!")
示例2: testExpectedConditionVisibilityOfElementLocated
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def testExpectedConditionVisibilityOfElementLocated(self, driver, pages):
pages.load("javascriptPage.html")
with pytest.raises(TimeoutException):
WebDriverWait(driver, 0.7).until(EC.visibility_of_element_located((By.ID, 'clickToHide')))
driver.find_element_by_id('clickToShow').click()
element = WebDriverWait(driver, 5).until(EC.visibility_of_element_located((By.ID, 'clickToHide')))
assert element.is_displayed() is True
示例3: testExpectedConditionInvisiblityOfElementLocated
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def testExpectedConditionInvisiblityOfElementLocated(self, driver, pages):
pages.load("javascriptPage.html")
driver.execute_script("delayedShowHide(0, true)")
with pytest.raises(TimeoutException):
WebDriverWait(driver, 0.7).until(EC.invisibility_of_element_located((By.ID, 'clickToHide')))
driver.execute_script("delayedShowHide(200, false)")
element = WebDriverWait(driver, 0.7).until(EC.invisibility_of_element_located((By.ID, 'clickToHide')))
assert element.is_displayed() is False
示例4: get_library_item
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def get_library_item(self, item_name):
""" Return element for library item `item_name`. """
xpath = "//table[(@id='objtypetable')]//td[(@modpath='%s')]" % item_name
library_item = WebDriverWait(self.browser, TMO).until(
lambda browser: browser.find_element_by_xpath(xpath))
WebDriverWait(self.browser, TMO).until(
lambda browser: library_item.is_displayed())
return library_item
示例5: get_waited_invisible_element
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def get_waited_invisible_element(self, css_selector):
element = WebDriverWait(self.browser, 10).until(
EC.invisibility_of_element_located((
By.CSS_SELECTOR, css_selector))
)
self.assertIsNotNone(element)
self.assertFalse(element.is_displayed())
return element
示例6: is_element_present
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def is_element_present(self, path):
element = WebDriverWait(self.driver, 10).until(
lambda driver: driver.find_element_by_xpath(path)
)
if element.is_displayed():
return True
else:
return False
示例7: is_news_description_visible
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def is_news_description_visible(self):
element = WebDriverWait(self.driver, 10).until(
lambda driver: driver.find_element_by_xpath(self.news_description)
)
if element.is_displayed():
return True
else:
return False
示例8: testExpectedConditionInvisiblityOfElement
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def testExpectedConditionInvisiblityOfElement(driver, pages):
pages.load("javascriptPage.html")
target = driver.find_element_by_id('clickToHide')
driver.execute_script("delayedShowHide(0, true)")
with pytest.raises(TimeoutException):
WebDriverWait(driver, 0.7).until(EC.invisibility_of_element(target))
driver.execute_script("delayedShowHide(200, false)")
element = WebDriverWait(driver, 0.7).until(EC.invisibility_of_element(target))
assert element.is_displayed() is False
assert target == element
示例9: testExpectedConditionVisibilityOfElementLocated
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def testExpectedConditionVisibilityOfElementLocated(self):
self._loadPage("javascriptPage")
try:
WebDriverWait(self.driver, 0.7).until(EC.visibility_of_element_located((By.ID, 'clickToHide')))
self.fail("Expected TimeoutException to have been thrown")
except TimeoutException as e:
pass
self.driver.find_element_by_id('clickToShow').click()
element = WebDriverWait(self.driver, 5).until(EC.visibility_of_element_located((By.ID, 'clickToHide')))
self.assertTrue(element.is_displayed())
示例10: testExpectedConditionInvisiblityOfElementLocated
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def testExpectedConditionInvisiblityOfElementLocated(self, driver, pages):
if driver.capabilities['browserName'] == 'firefox' and driver.w3c:
pytest.xfail("Marionette issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1297551")
pages.load("javascriptPage.html")
driver.execute_script("delayedShowHide(0, true)")
with pytest.raises(TimeoutException):
WebDriverWait(driver, 0.7).until(EC.invisibility_of_element_located((By.ID, 'clickToHide')))
driver.execute_script("delayedShowHide(200, false)")
element = WebDriverWait(driver, 0.7).until(EC.invisibility_of_element_located((By.ID, 'clickToHide')))
assert element.is_displayed() is False
示例11: testExpectedConditionInvisiblityOfElementLocated
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def testExpectedConditionInvisiblityOfElementLocated(self):
self._loadPage("javascriptPage")
self.driver.execute_script("delayedShowHide(0, true)")
try:
WebDriverWait(self.driver, 0.7).until(EC.invisibility_of_element_located((By.ID, 'clickToHide')))
self.fail("Expected TimeoutException to have been thrown")
except TimeoutException as e:
pass
self.driver.execute_script("delayedShowHide(200, false)")
element = WebDriverWait(self.driver, 0.7).until(EC.invisibility_of_element_located((By.ID, 'clickToHide')))
self.assertFalse(element.is_displayed())
示例12: then_i_should_see_landing_page
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def then_i_should_see_landing_page(step, landing_page):
if landing_page == "Dashboard":
dashboard = world.driver.find_element_by_css_selector(".dashboard-home")
if not dashboard.is_displayed():
world.log.info("No dashboard is presented.")
raise AssertionError
elif landing_page == "Internal Contact Entities":
dashboard = WebDriverWait(world.driver, 60).until(EC.presence_of_element_located((By.CSS_SELECTOR,
".entities-list")))
#dashboard = world.driver.find_element_by_css_selector(".entities-list")
if not dashboard.is_displayed():
world.log.info("No internal contact entities page is presented.")
raise AssertionError
示例13: check_for_connection
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def check_for_connection(self):
while 1:
element = WebDriverWait(self.browser, 10).until(
EC.presence_of_element_located((By.ID, "accept_new_partner"))
)
chat_input_element = self.browser.find_element_by_id("chat_input")
check_this = chat_input_element.is_displayed()
condition = element.is_displayed()
if condition or check_this :
if condition:
element.click()
accepted_rec = Testing.get_date_time()
Testing.open_log_file(accepted_rec, 'accepted_connection', self.username)
Testing.checking_for_msg()
return True
示例14: test_has_date_and_time_picker_widget
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def test_has_date_and_time_picker_widget(self):
datetime_picker_icon = self.selenium.find_element_by_class_name('glyphicon-calendar')
ActionChains(self.selenium).click(datetime_picker_icon).perform()
try:
datetime_picker_widget = WebDriverWait(self.selenium, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, 'bootstrap-datetimepicker-widget'))
)
active_day = datetime_picker_widget.find_element_by_class_name('active')
ActionChains(self.selenium).click(active_day).perform()
selected_datetime = self.selenium.find_element_by_id('id_visit_schedule').get_attribute('value')
self.assertTrue(datetime_picker_widget.is_displayed())
self.assertEqual(time.strftime('%m/%d/%Y %I: %p'),
time.strftime('%m/%d/%Y %I: %p', time.strptime(selected_datetime, '%m/%d/%Y %I:%M %p')))
except TimeoutException as e:
self.fail('Unable to Execute Test Properly')
示例15: get_library_item
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_displayed [as 别名]
def get_library_item(self, item_name):
""" Return element for library item `item_name`. """
xpath = "//table[(@id='objtypetable')]//td[(@modpath='%s')]" % item_name
library_item = WebDriverWait(self.browser, TMO).until(
lambda browser: browser.find_element_by_xpath(xpath))
for retry in range(3):
try:
WebDriverWait(self.browser, TMO).until(
lambda browser: library_item.is_displayed())
except StaleElementReferenceException:
if retry < 2:
logging.warning('get_library_item:'
' StaleElementReferenceException')
library_item = WebDriverWait(self.browser, TMO).until(
lambda browser: browser.find_element_by_xpath(xpath))
else:
raise
else:
break
return library_item