本文整理汇总了Python中selenium.webdriver.support.expected_conditions.visibility_of函数的典型用法代码示例。如果您正苦于以下问题:Python visibility_of函数的具体用法?Python visibility_of怎么用?Python visibility_of使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了visibility_of函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_add_indicator_to_iList
def test_add_indicator_to_iList(self):
login(self.driver)
create_iList(self.driver)
self.driver.refresh()
'''since we know the filter works from TestDataCatalogSearch,
we don't need to search filters again here. This will avoid
having to use WebDriverWait() which can sometimes cause
conflict with ajax requests.
'''
self.driver.get(S.CATALOG_FILTER_URL)
indicator_from_search_elem = self.driver.find_element_by_css_selector('.odd a')
indicator_from_search = indicator_from_search_elem.text
indicator_from_search_ckbx = self.driver.find_element_by_css_selector('.odd input')
indicator_from_search_ckbx.click()
add_btn = self.driver.find_element_by_id('indicator_list_actions_add_to_ilist')
add_btn.click()
self.driver.get(S.USER_PORTFOLIO_URL)
self.driver.refresh()
iList_to_edit = WebDriverWait(self.driver, 10).until(EC.visibility_of(self.driver.find_element_by_css_selector('.edit_ilist')))
iList_to_edit.click()
indicator_in_iList_elem = WebDriverWait(self.driver, 10).until(EC.visibility_of(self.driver.find_element_by_id('indicator_2362')))
indicator_in_iList = indicator_in_iList_elem.text
self.assertEqual(indicator_from_search, indicator_in_iList)
sign_out(self.driver)
开发者ID:ProvidencePlan,项目名称:DatahubQA,代码行数:32,代码来源:TestAddDeleteIndicatorsToiLists.py
示例2: test_chrome_app_link
def test_chrome_app_link():
# The web driver for Safari does not yet support the move_to_element method so this test will not function properly
if (driver.capabilities['browserName'] == "safari"):
raise SkipTest
driver.get(testcenter_url + 'en')
button = driver.find_element_by_xpath('//div[@id="app"]/section[1]/div[1]/div[1]/div[1]/div/div')
hoverButton = ActionChains(driver).move_to_element(button)
hoverButton.perform()
loginBox = driver.find_element_by_xpath('//div[@id="app"]/section[1]/div[1]/div[2]/p')
chromeLink = driver.find_element_by_css_selector('.start-chrome')
wait = WebDriverWait(driver, 30)
wait.until(EC.visibility_of(chromeLink))
if chromeLink.is_displayed():
chromeLink.click()
# Users are redirected to a user creation page if they are not currently logged in when using Chrome
# If they are using other browsers, they are redirected to a Chrome download page
if driver.capabilities['browserName'] == 'chrome':
wait = WebDriverWait(driver, 30)
wait.until(EC.visibility_of(loginBox))
loginText = driver.find_element_by_xpath('//div[@id="app"]/section[1]/div[1]/div[2]/p').text.strip()
assert (loginText == "You need a Duolingo account to save your test results.")
else:
try:
elem = driver.find_element_by_xpath("//*[contains(.,'Download Chrome')]")
assert True
except:
assert False
开发者ID:vinyaa,项目名称:Deliverable4,代码行数:29,代码来源:test.py
示例3: login_user
def login_user(self):
"""
Taken from account views tests
FIXME: Ideally this can be deleted and user authenitcation can happen in setUp
"""
# Login user
# 1. Go to home page and confirm successful load
home_url = reverse('index')
self.browser.get(self.live_server_url + home_url)
actual = self.browser.current_url
expected = self.live_server_url + u'/'
self.assertEqual(actual, expected)
# 2. Click 'Login' modal link in header
login_link = self.browser.find_element_by_css_selector(
'p[data-target="#Login-Modal"]')
login_link.click()
# 3. Confirm Login modal appears
login_modal = self.browser.find_element_by_css_selector('#Login-Modal')
wait = WebDriverWait(self.browser, 10)
element = wait.until(EC.visibility_of(login_modal))
actual = login_modal.is_displayed()
expected = True
self.assertEqual(actual, expected)
self.browser.save_screenshot('login_modal.png')
# 4. Enter email and password
email_input = self.browser.find_element_by_css_selector('#id_username')
password_input = self.browser.find_element_by_css_selector('#id_password')
wait = WebDriverWait(self.browser, 10)
element = wait.until(EC.visibility_of(password_input))
email_input.send_keys(self.user_email)
password_input.send_keys(self.user_password)
password_input.submit()
# 5. Refresh page to show featured facilities
self.browser.save_screenshot('logged_in.png')
开发者ID:crazyfln,项目名称:hfg-1,代码行数:34,代码来源:views.py
示例4: test_mobile_home_page_aesthetics
def test_mobile_home_page_aesthetics(self):
self.browser.get(self.server_url)
# Basic intro text is displayed
self.assert_text_in_body(
'Search millions of opinions by case name, topic, or citation.'
)
# on mobile, the navbar should start collapsed into a hamburger-esque
# icon in the upper right
navbar_header = (self.browser
.find_element_by_css_selector('.navbar-header'))
navbtn = navbar_header.find_element_by_tag_name('button')
self.assertIn('collapsed', navbtn.get_attribute('class'))
self.assertAlmostEqual(
navbtn.location['x'] + navbtn.size['width'] + 10,
MOBILE_WINDOW[0],
delta=10
)
# clicking the button displays and then hides the menu
menu = self.browser.find_element_by_css_selector('.nav')
self.assertFalse(menu.is_displayed())
navbtn.click()
WebDriverWait(self.browser, 5).until(EC.visibility_of(menu))
self.assertTrue(menu.is_displayed())
# and the menu is width of the display
self.assertAlmostEqual(
menu.size['width'],
MOBILE_WINDOW[0],
delta=5
)
# and the menu hides when the button is clicked
navbtn.click()
WebDriverWait(self.browser, 5).until_not(EC.visibility_of(menu))
self.assertFalse(menu.is_displayed())
# search box should always be centered
searchbox = self.browser.find_element_by_id('id_q')
search_button = self.browser.find_element_by_id('search-button')
juri_select = self.browser.find_element_by_css_selector(
'div[data-content="Select Jurisdictions"]'
)
search_width = (searchbox.size['width'] +
search_button.size['width'] +
juri_select.size['width'])
self.assertAlmostEqual(
searchbox.location['x'] + search_width / 2,
MOBILE_WINDOW[0] / 2,
delta=10
)
# and the search box should be ~250px wide in mobile layout
self.assertAlmostEqual(
searchbox.size['width'],
250,
delta=5
)
开发者ID:Andr3iC,项目名称:courtlistener,代码行数:60,代码来源:test_layout.py
示例5: test_delete_indicator_from_iList
def test_delete_indicator_from_iList(self):
login(self.driver)
self.driver.get(S.USER_PORTFOLIO_URL)
iList_to_edit = WebDriverWait(self.driver, 10).until(EC.visibility_of(self.driver.find_element_by_css_selector('.edit_ilist')))
iList_to_edit.click()
indicator_ckbx = WebDriverWait(self.driver, 10).until(EC.visibility_of(self.driver.find_element_by_name("indicator_id")))
indicator_ckbx.click()
remove_selected_btn = self.driver.find_element_by_id("indicator_list_lightbox_remove_selected")
remove_selected_btn.click()
exit_lightbox_btn = self.driver.find_element_by_id("cboxClose")
exit_lightbox_btn.click()
self.driver.refresh()
iList_to_edit = WebDriverWait(self.driver, 10).until(EC.visibility_of(self.driver.find_element_by_css_selector('.edit_ilist')))
iList_to_edit.click()
empty_table_elem = WebDriverWait(self.driver, 10).until(EC.visibility_of(self.driver.find_element_by_class_name("dataTables_empty")))
empty_table_txt = empty_table_elem.text
self.assertEqual(empty_table_txt, 'No data available in table')
sign_out(self.driver)
开发者ID:ProvidencePlan,项目名称:DatahubQA,代码行数:26,代码来源:TestAddDeleteIndicatorsToiLists.py
示例6: login
def login(self):
"signs in as test/[email protected]/test"
driver = self.driver
with Annotator(driver):
# Find the signin link and click it
signin = driver.find_element_by_link_text("Sign in")
ec = expected_conditions.visibility_of(signin)
WebDriverWait(driver, 30).until(ec)
signin.click()
# Find the authentication form sheet
auth = driver.find_element_by_class_name('sheet')
# Find the login pane
form = auth.find_element_by_name('login')
ec = expected_conditions.visibility_of(form)
WebDriverWait(driver, 30).until(ec)
username = form.find_element_by_name('username')
username.send_keys("test")
password = form.find_element_by_name('password')
password.send_keys("test")
form.submit()
开发者ID:RichardLitt,项目名称:h,代码行数:25,代码来源:__init__.py
示例7: test_contact_key_creator
def test_contact_key_creator(self):
self.logger.info('Starting test_contact_key_creator')
#setup the doc on gdrive first
file_name = 'ContactKeyTest1'
ss_key = gdoc_util.upload_file_to_gdrive('contact_key_test1.tsv', file_name)
driver = self.driver
gdoc_util.login_gdrive(driver)
driver.get('%s%s' % (self.base_url, '?ss=' + ss_key))
gc = gspread.login(settings.DEFAULT_GDRIVE_EMAIL, settings.DEFAULT_GDRIVE_PW)
my_worksheet = gc.open_by_key(ss_key).sheet1
e2_val = my_worksheet.acell('E2')
self.logger.info('e2_val: %s' % e2_val)
#reset the cell
my_worksheet.update_acell('E2', '')
e2_val = my_worksheet.acell('E2')
self.logger.info('e2_val reset to: %s' %e2_val)
#now run the command
#switch to input form frame
driver.switch_to.frame(0)
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.LINK_TEXT, "Hiplead"))
).click()
id_worksheet_name_INPUT = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "id_worksheet_name"))
)
id_worksheet_name_INPUT.clear()
id_worksheet_name_INPUT.send_keys(file_name)
Select(driver.find_element_by_id("id_scrapers")).select_by_value('contactKeyCreator')
driver.find_element_by_id("id_email").send_keys(settings.DEFAULT_GDRIVE_EMAIL)
driver.find_element_by_id("id_password").send_keys(settings.DEFAULT_GDRIVE_PW)
#ok, now submit the form
id_worksheet_name_INPUT.submit()
#then wait for task to complete
#this success alert only becomes visible when task is actually finished.
success_div = driver.find_element_by_class_name('time_remaining')
try:
WebDriverWait(driver, 10).until(
EC.visibility_of(success_div)
)
except StaleElementReferenceException as e:
#TODO The javascript DOM manipulation that results in StaleElementReferenceException needs to be resolved.
success_div = driver.find_element_by_class_name('time_remaining')
WebDriverWait(driver, 10).until(
EC.visibility_of(success_div)
)
#now validate cell value, since we know task has completed.
e2_val = my_worksheet.acell('E2')
self.logger.info('e2_val after test: %s' %e2_val)
self.assertEquals('john_franklin_smith_somedomain.net', e2_val.value)
self.logger.info( 'Finished test_contact_key_creator')
开发者ID:edhiptest,项目名称:test_automation_base,代码行数:60,代码来源:test_contactkey_creator.py
示例8: register
def register(self):
"registers as test/[email protected]/test"
driver = self.driver
with Annotator(driver):
# Find the signin link and click it
signin = driver.find_element_by_link_text("Sign in")
ec = expected_conditions.visibility_of(signin)
WebDriverWait(driver, 30).until(ec)
signin.click()
# Find the authentication form sheet
auth = driver.find_element_by_class_name('sheet')
# Switch to the registration tab
auth.find_element_by_link_text("Create an account").click()
# Get the registration pane
form = auth.find_element_by_name('register')
ec = expected_conditions.visibility_of(form)
WebDriverWait(driver, 30).until(ec)
username = form.find_element_by_name('username')
username.send_keys("test")
email = form.find_element_by_name('email')
email.send_keys("[email protected]")
password = form.find_element_by_name('password')
password.send_keys("test")
form.submit()
picker = (By.CLASS_NAME, 'user-picker')
ec = expected_conditions.visibility_of_element_located(picker)
WebDriverWait(self.driver, 30).until(ec)
开发者ID:RichardLitt,项目名称:h,代码行数:35,代码来源:__init__.py
示例9: testExpectedConditionVisibilityOf
def testExpectedConditionVisibilityOf(self, driver, pages):
pages.load("javascriptPage.html")
hidden = driver.find_element_by_id('clickToHide')
with pytest.raises(TimeoutException):
WebDriverWait(driver, 0.7).until(EC.visibility_of(hidden))
driver.find_element_by_id('clickToShow').click()
element = WebDriverWait(driver, 5).until(EC.visibility_of(hidden))
assert element.is_displayed() is True
开发者ID:zhjwpku,项目名称:selenium,代码行数:8,代码来源:webdriverwait_tests.py
示例10: test_accordion_minimize_by_double_click
def test_accordion_minimize_by_double_click(self):
"""Accordion item should be minimized by two clicks on title."""
accordion_title = self.accordion_title
accordion_content = self.accordion_content
accordion_title.click()
self.wait.until(EC.visibility_of(accordion_content))
accordion_title.click()
self.wait.until_not(EC.visibility_of(accordion_content))
self.assertFalse(accordion_content.is_displayed())
开发者ID:fidals,项目名称:shopelectro,代码行数:10,代码来源:tests_selenium.py
示例11: testExpectedConditionVisibilityOf
def testExpectedConditionVisibilityOf(self):
self._loadPage("javascriptPage")
hidden = self.driver.find_element_by_id('clickToHide')
try:
WebDriverWait(self.driver, 0.7).until(EC.visibility_of(hidden))
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(hidden))
self.assertTrue(element.is_displayed())
开发者ID:NextGenIntelligence,项目名称:selenium,代码行数:11,代码来源:webdriverwait_tests.py
示例12: test_multi_stash
def test_multi_stash(self):
self.login()
self.open(reverse('admin:test_app_testmodeladvanced_change', args=[self.advanced.id]))
inline = self.webdriver.find_css("#testinlinemodel_set-group")
wait = WebDriverWait(self.webdriver, 1)
wait.until(visibility_of(inline))
# self.assertTrue(inline.is_displayed())
f11 = self.webdriver.find_css("div.field-set1_1")
wait.until(visibility_of(f11))
# self.assertTrue(f11.is_displayed())
f31 = self.webdriver.find_css("div.field-set3_1")
wait.until(invisibility_of(f31))
开发者ID:benzkji,项目名称:django-formfieldstash,代码行数:12,代码来源:test_admin.py
示例13: test_amvr
def test_amvr(self):
driver = self.driver
waiting = self.waiting
driver.get("https://apps.tn.gov/amvr-app/login.html")
waiting.until(expected_conditions.title_is("Log In - Motor Vehicle Records Search"))
username_textbox = waiting.until(expected_conditions.visibility_of(driver.find_element_by_id("username")))
password_textbox = waiting.until(expected_conditions.visibility_of(driver.find_element_by_id("password")))
login_button = waiting.until(expected_conditions.visibility_of(driver.find_element_by_name("login")))
waiting.until(expected_conditions.title_is("Log In - Motor Vehicle Records Search"))
self.assertIn("amvr-app/login.html", driver.current_url, "Failed to login")
开发者ID:shawnknight,项目名称:test_project,代码行数:13,代码来源:amvr_test.py
示例14: search
def search(self, search_term):
"""
Searches for an app using the available search field
:Args:
- search_term - string value of the search field
"""
search_toggle = self.selenium.find_element(*self._search_toggle_locator)
WebDriverWait(self.selenium, self.timeout).until(EC.visibility_of(search_toggle))
search_toggle.click()
search_field = self.selenium.find_element(*self._search_input_locator)
WebDriverWait(self.selenium, self.timeout).until(EC.visibility_of(search_field))
search_field.send_keys(search_term)
search_field.submit()
from pages.desktop.consumer_pages.search import Search
return Search(self.testsetup, search_term)
开发者ID:bobsilverberg,项目名称:marketplace-tests,代码行数:15,代码来源:base.py
示例15: public
def public(self, value):
if self.public == value:
return
# If public, the "Make private" element will be the only <a>.
# If private, the opposite is true.
self.driver.find_element_by_css_selector(
'#overview div.btn-group:nth-of-type(1) > a'
).click()
WebDriverWait(self.driver, 3).until(
EC.visibility_of_element_located(
(By.CSS_SELECTOR, 'div.modal.fade.in button.btn-primary')
)
)
confirm_button = self.driver.find_element_by_css_selector(
'div.modal.fade.in button.btn-primary'
)
WebDriverWait(self.driver, 1).until(
EC.visibility_of(confirm_button)
)
with WaitForPageReload(self.driver):
confirm_button.click()
开发者ID:chennan47,项目名称:osf-ui-tests,代码行数:26,代码来源:project.py
示例16: wait_for_visible_element
def wait_for_visible_element(self,
web_element=None,
locator=None,
wait_period=None):
"""Pause until the element is displayed/visible
Selenium Driver will wait for the web element to be visible.
The web element can be provided as a Selenium Web Element or as
an Element Locator Tuple
:param web_element: Optional argument. Default value of None
:type web_element: Selenium Web Element Object
:param locator: Optional argument. Default value of None
:type locator: Tuple of two items: Locator Type and Locator String
:param wait_period: Optional argument. Seconds to wait for the Web
Element to be displayed. Default value of None
:type wait_period: int
"""
wait = self.ui_config.page_load_timeout if wait_period is None \
else wait_period
if web_element is not None:
WebDriverWait(
self.driver,
wait).until(
EC.visibility_of(web_element))
else:
WebDriverWait(
self.driver,
wait).until(
EC.visibility_of_element_located(locator))
开发者ID:sujala,项目名称:Test,代码行数:31,代码来源:page.py
示例17: wait_until_element_is_visible
def wait_until_element_is_visible(driver, element, timeout):
"""Waits until a DOM element is visible within a given timeout.
Args:
driver: An instance of a Selenium webdriver browser class.
element: A Selenium webdriver element.
timeout: The maximum time to wait (in seconds).
Returns:
True if the element became visible within the timeout.
"""
try:
# Apparently checks for an element's visibility are broken in Safari 10.
# For addtional (though not much) information, see:
# http://stackoverflow.com/questions/40635371/selenium-3-0-1-with-safaridriver-failing-on-waitforelementvisible
# https://groups.google.com/forum/#!msg/selenium-users/xEGcK92rzVg/IboybWUPAAAJ
#
# To get around this for now, check the browser name and version (WebKit
# version , really), and if they seem to indicate Safari 10, then do a
# dumb wait of 'timeout' seconds to give the page time to render and the
# elements to become visible, etc.
if (driver.capabilities['browserName'] == 'safari' and
driver.capabilities['version'] == SAFARI10_VERSION):
time.sleep(timeout)
else:
ui.WebDriverWait(
driver,
timeout).until(expected_conditions.visibility_of(element))
except exceptions.TimeoutException:
return False
return True
开发者ID:m-lab,项目名称:ndt-e2e-clientworker,代码行数:31,代码来源:browser_client_common.py
示例18: logout
def logout(self):
# If present, close the "new branding" overlay as it blocks logging out
elems = self.driver.find_elements_by_id("self.webklipper-publisher-widget-container-notification-close-div")
self.assertFalse(
len(elems) > 1,
"Found more than one element with the id: "
+ "webklipper-publisher-widget-container-notification-close-div",
)
if len(elems) == 1:
elems[0].click()
self.driver.get("http://" + self.DOMAIN + self.DASHBOARD)
try:
elem = self.wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".fn-hover-menu.span-7")))
except TimeoutException as te:
print(te.msg)
# check if logged in
self.assertTrue(
self.wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "a[href='/accounts/login/']")))
)
return
self.assertTrue(elem is not None, "Failed to find hoverable element used to make logout link visible")
hover = ActionChains(self.driver).move_to_element(elem)
hover.perform()
elem = self.wait.until(
EC.visibility_of(self.driver.find_element_by_css_selector("a[href='/accounts/logout/']"))
)
elem.click()
self.elem = self.wait.until(EC.presence_of_element_located((By.XPATH, "//a[@href='/accounts/login/']")))
开发者ID:jackeymason,项目名称:FNSelenium,代码行数:30,代码来源:FNSeleniumBaseClass.py
示例19: _remove_test_user_from_db
def _remove_test_user_from_db(self):
self.driver.get(S.ADMIN_LOGIN_PAGE)
admin_username = self.driver.find_element_by_id('id_username')
admin_username.send_keys(S.SUPERUSER_USERNAME)
admin_password = self.driver.find_element_by_id('id_password')
admin_password.send_keys(S.SUPERUSER_PASSWORD)
admin_password.send_keys(Keys.RETURN)
#this searches the test username directly into url, less complications w/selenium
self.driver.get(S.USERNAME_SEARCH_URL)
username_link = WebDriverWait(self.driver, 10).until(EC.visibility_of(self.driver.find_element_by_link_text('testtestspaceorg')))
#ensures that this test name is actually in the db
self.assertEqual(username_link.text,'testtestspaceorg')
username_link.click()
delete_btn = self.driver.find_element_by_class_name('deletelink')
delete_btn.click()
confirm_btn = self.driver.find_element_by_css_selector('input[type="submit"]')
confirm_btn.click()
logout_btn = self.driver.find_element_by_css_selector('a[href="/admin/logout/"]')
logout_btn.click()
开发者ID:ProvidencePlan,项目名称:DatahubQA,代码行数:27,代码来源:TestNewAccount.py
示例20: getCounts
def getCounts(employer):
'''
takes the company name and returns the number of
applications submitted during the period between
the first and second elements of the dates obj
'''
global driver
if (len(driver.find_elements_by_css_selector('#visa_h1b1'))==0):
driver.back()
driver.implicitly_wait(3)
driver.find_element_by_id("visa_h1b1").click()
elem1 = driver.find_element_by_id('employer_business_name')
elem1.clear()
elem1.send_keys(employer)
elem2 = driver.find_element_by_id('start_date_from')
elem2.clear()
elem2.send_keys(dates[0])
elem3 = driver.find_element_by_id('start_date_to')
elem3.clear()
elem3.send_keys(dates[1])
driver.find_element_by_id('btnSearch_employment2').click()
elem = driver.find_element_by_id('numberOfCaseFound')
wait = WebDriverWait(driver, 5)
count = wait.until(EC.visibility_of(elem)).text
return int(count.replace(',',''))
开发者ID:nycdatasci,项目名称:online_bootcamp_project,代码行数:34,代码来源:s-scraper.py
注:本文中的selenium.webdriver.support.expected_conditions.visibility_of函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论