本文整理汇总了Python中selenium.webdriver.support.ui.WebDriverWait.is_selected方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.is_selected方法的具体用法?Python WebDriverWait.is_selected怎么用?Python WebDriverWait.is_selected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.ui.WebDriverWait
的用法示例。
在下文中一共展示了WebDriverWait.is_selected方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: queryUnAcked
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_selected [as 别名]
def queryUnAcked(driver):
# i_ack_status
btnList = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//div[@id='i_ack_status']/div/button")))
btnList.click()
checkUnAck = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//div[@id='i_ack_status']/div/div/div[2]/label/input")))
if (not checkUnAck.is_selected()):
checkUnAck.click()
btnList.click()
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "idBtn-search"))).click()
示例2: TestValidLogin
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_selected [as 别名]
class TestValidLogin(unittest.TestCase):
def setUp(self):
self.apps_url = "http://7themes.su/"
self.valid_login = 'bspqsxaq'
self.valid_password = 'jajhvktybt'
self.invalid_password = '2jajhvktybt'
self.driver = webdriver.Chrome(executable_path="/opt/chromedriver")
self.driver.maximize_window()
self.driver.get(self.apps_url)
def test_login_to_site_login_valid_password_valid(self):
''' Enter with valid login and valid password '''
#autorization link
self.authorization_link = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.CLASS_NAME, 'signin')))
self.authorization_link.click()
#autorization name field
self.authorization_name_field = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'user')))
self.authorization_name_field.send_keys(self.valid_login)
#authorization password field
self.authorization_password_field = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'password')))
self.authorization_password_field.send_keys(self.valid_password)
#checkbox "remember user"
self.checkbox = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'rem')))
if (self.checkbox.is_selected()):
self.checkbox.click() #check box "Remember me" must bu uncheked before submit
#submit login with password
self.submit = WebDriverWait(self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'sbm')))
self.submit.click() #submit login with password
#verify valid logon
self.loginned_text_must_be = self.valid_login + "!"
time.sleep(4)
self.assertTrue(self.loginned_text_must_be in self.driver.page_source)
self.driver.save_screenshot("file1.png")
os.makedirs('test_result/screenshots')
self.driver.save_screenshot("test_result/screenshots/file2.png")
print (os.path)
def tearDown(self):
self.driver.close()
示例3: choose_place
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_selected [as 别名]
def choose_place(self):
place_wrapper = WebDriverWait(self.driver, 30, 0.1).until(
lambda d: d.find_element_by_css_selector(self.PLACE_WRAPPER)
)
place_rus = WebDriverWait(place_wrapper, 30, 0.1).until(
lambda d: d.find_element_by_css_selector(self.PLACE_RUS)
)
place_rus_btn = WebDriverWait(place_rus, 30, 0.1).until(
lambda d: d.find_element_by_css_selector(self.CHECKBOX)
)
if not place_rus_btn.is_selected():
place_rus_btn.click()
place_rus_btn.get_attribute('checked')
示例4: test_AllinAll
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_selected [as 别名]
def test_AllinAll(self):
driver = self.driver
element = driver.get(self.url)
driver.maximize_window()
print(driver.title)
WebDriverWait(driver,10).until(lambda driver : driver.title.lower().startswith('flights'))
self.assertIn("Flights | Frontier Airlines",driver.title)
main_image = WebDriverWait(driver,10).until(lambda driver : driver.find_element_by_xpath(".//div[@id='js_dynamic_header_image']"))
try :
WebDriverWait(driver,10).until(EC.visibility_of_element_located(By.XPATH,".//div[@id='js_dynamic_header_image']"))
except TypeError:
pass
if main_image.is_displayed() :
print("Main image is displayed")
else :
print("Main image is not displayed")
roundtrip = WebDriverWait(driver,10).until(lambda driver : driver.find_element_by_xpath(".//label[contains(.,'Round-trip')]"))
if roundtrip.is_selected() :
print("Round Trip is selected by default")
else :
print("Round Trip is not selected")
Oneway = WebDriverWait(driver,10).until(lambda driver : driver.find_element_by_xpath(".//label[contains(.,'One-way')]"))
if Oneway.is_selected() :
print("Error")
else :
print("Good to go")
print(driver.current_url)
bottom_options = WebDriverWait(driver,10).until(lambda driver : driver.find_element_by_xpath(".//*[@class='corp-images-container']"))
bottom_iter = bottom_options.find_elements_by_tag_name('span')
options_list = [x for x in bottom_iter]
print(options_list)
footer_options = WebDriverWait(driver,10).until(lambda driver : driver.find_element_by_xpath(".//*[@class='inline footer-link-list last-link-list']"))
footer_iter = footer_options.find_elements_by_tag_name('a')
for x in footer_iter :
print(x.text)
示例5: choose_place_without_one_region
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_selected [as 别名]
def choose_place_without_one_region(self):
place_wrapper = WebDriverWait(self.driver, 30, 0.1).until(
lambda d: d.find_element_by_css_selector(self.PLACE_WRAPPER)
)
place_rus = WebDriverWait(place_wrapper, 30, 0.1).until(
lambda d: d.find_element_by_css_selector(self.PLACE_RUS)
)
place_rus.find_element_by_css_selector(self.PLACE_ICON).click()
wrapper = place_rus.find_element_by_css_selector(self.AMUR)
place_amur = WebDriverWait(wrapper, 30, 0.1).until(
lambda d: d.find_element_by_css_selector(self.CHECKBOX)
)
if place_amur.is_selected():
place_amur.click()
示例6: TestInvalidLogin
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_selected [as 别名]
class TestInvalidLogin(unittest.TestCase):
def setUp(self):
self.apps_url = "http://7themes.su/"
self.valid_login = 'bspqsxaq'
self.invalid_password = '2jajhvktybt'
self.driver = webdriver.Chrome(executable_path="/opt/chromedriver")
self.driver.maximize_window()
self.driver.get(self.apps_url)
def test_enter_valid_login_invalid_password(self):
''' Enter with valid login and invalid password '''
#autorization link
self.authorization_link = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.CLASS_NAME, 'signin')))
self.authorization_link.click()
#autorization name field
self.authorization_name_field = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'user')))
self.authorization_name_field.send_keys(self.valid_login)
#authorization password field
self.authorization_password_field = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'password')))
self.authorization_password_field.send_keys(self.invalid_password)
#checkbox "remember user"
self.checkbox = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'rem')))
if (self.checkbox.is_selected()):
self.checkbox.click() #check box "Remember me" must bu uncheked before submit
#submit login with password
self.submit = WebDriverWait(self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'sbm')))
self.submit.click() #submit login with password
#error message
self.error_message = WebDriverWait(self.driver, 10).until(
ec.visibility_of_element_located((By.CLASS_NAME, 'myWinError')))
def tearDown(self):
self.driver.close()
开发者ID:dmytrobondarchuk,项目名称:7themes_tests,代码行数:48,代码来源:test_enter_to_site_with_valid_login_invalid_password.py
示例7: use_within_unit_prevalence
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_selected [as 别名]
def use_within_unit_prevalence(self, enable_prevalence, timeout=None):
"""Enables or disables use of within-unit prevalence."""
if timeout is None:
timeout = self.default_timeout
self.click_navbar_element('Disease')
# Wait for the checkbox to appear
checkbox = WebDriverWait(self.selenium, timeout=timeout).until(
EC.visibility_of_element_located((By.NAME, 'use_within_unit_prevalence'))
)
# If enable_prevalence==True and the checkbox is not checked, click it to check.
# If enable_prevalence==False and the checkbox is checked, click it to un-check.
if enable_prevalence != checkbox.is_selected():
checkbox.click()
# Save the changes we just made.
self.find('.btn-save').click()
return
示例8: TestLoginToSite
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_selected [as 别名]
class TestLoginToSite(unittest.TestCase):
def setUp(self):
self.apps_url = "http://7themes.su/"
self.valid_login = 'bspqsxaq'
self.valid_password = 'jajhvktybt'
self.invalid_password = '2jajhvktybt'
self.driver = webdriver.Chrome(executable_path="/opt/chromedriver")
self.driver.maximize_window()
self.driver.get(self.apps_url)
def test_login_to_site_with_valid_login_and_valid_password(self):
''' Tests login to site with valid login and valid password '''
#autorization link
self.authorization_link = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.CLASS_NAME, 'signin')))
self.authorization_link.click()
#autorization name field
self.authorization_name_field = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'user')))
self.authorization_name_field.send_keys(self.valid_login)
#authorization password field
self.authorization_password_field = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'password')))
self.authorization_password_field.send_keys(self.valid_password)
#checkbox "remember user"
self.checkbox = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'rem')))
if (self.checkbox.is_selected()):
self.checkbox.click() #check box "Remember me" must bu uncheked before submit
#submit login with password
self.submit = WebDriverWait(self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'sbm')))
self.submit.click() #submit login with password
#verify valid logon
self.loginned_text_must_be = self.valid_login + "!"
time.sleep(10)
self.assertTrue(self.loginned_text_must_be in self.driver.page_source)
def test_login_to_site_with_valid_login_and_invalid_password(self):
''' Tests login to site with valid login and invalid password '''
#autorization link
self.authorization_link = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.CLASS_NAME, 'signin')))
self.authorization_link.click()
#autorization name field
self.authorization_name_field = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'user')))
self.authorization_name_field.send_keys(self.valid_login)
#authorization password field
self.authorization_password_field = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'password')))
self.authorization_password_field.send_keys(self.invalid_password)
#checkbox "remember user"
self.checkbox = WebDriverWait (self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'rem')))
if (self.checkbox.is_selected()):
self.checkbox.click() #check box "Remember me" must bu uncheked before submit
#submit login with password
self.submit = WebDriverWait(self.driver, 10).until(
ec.visibility_of_element_located((By.NAME, 'sbm')))
self.submit.click() #submit login with password
#error message about invalid login or password
self.error_message = WebDriverWait(self.driver, 10).until(
ec.visibility_of_element_located((By.CLASS_NAME, 'myWinError')))
def tearDown(self):
self.driver.close()
示例9: test_f44
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_selected [as 别名]
def test_f44(self):
numerPracy = "112859"
driver = self.driver
driver.switch_to_window(driver.window_handles[1])
print "-------------okno: "+driver.title +"------------"
print driver.current_url
# ostatnia pozycja przed dodaniem wiersza
el = driver.find_elements_by_css_selector("tbody#here > tr")
print "lista id pozycji:"
for i in el:
print i.get_attribute('id')
e = [i.get_attribute('id') for i in el]
OstPozycja = str(max(e))
addGroupPositionBtn = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(".//*[@id='group_graphic_positions']/span"))
addGroupPositionBtn.click()
SearchGraphicEl = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_id("search_for_graphic"))
SearchGraphicEl.send_keys(numerPracy)
SearchGraphicEl.send_keys(Keys.ENTER)
selectAllBox = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(".//*[@id='job_summary']/table/tbody[1]/tr/th[1]/input"))
if not selectAllBox.is_selected():
selectAllBox.click()
wierszeCheckBx = driver.find_elements_by_css_selector("tbody#row_container > tr")
for i in wierszeCheckBx:
if not i.find_element_by_xpath(".//input").is_selected():
i.find_element_by_xpath(".//input").click()
tabelaZPracy = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_id("row_container"))
tabela = tabelaZPracy.text
NazwaKampanii = tabelaZPracy.find_element_by_xpath("./tr[1]/td[5]").text
NazwaMotywu = tabelaZPracy.find_element_by_xpath("./tr[1]/td[2]").text
PozZPracy = NazwaKampanii, NazwaMotywu
NazwaKampanii = str(NazwaKampanii)
DodajDoPoz = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(".//*[@id='get_for_invoice']/span"))
DodajDoPoz.click()
sciezkaOstWiersza= ".//*[@id='" +OstPozycja+"']/td[1]/input"
wierszOst = driver.find_element_by_xpath(sciezkaOstWiersza)
def saveElements():
save_elementsBtn = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_id("save_elements"))
save_elementsBtn.click()
def selectRow():
selectField = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(sciezkaOstWiersza))
selectField.click()
print "zaznaczono ostatnia pozycje do usuniecia"
def removeRow():
remRowBtn = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_id("remove_row"))
remRowBtn.click()
print "usunieto ost pozycje"
saveElements()
el2 = driver.find_elements_by_css_selector("tbody#here > tr")
e2 = [i.get_attribute('id') for i in el2]
OstPozycja2 = str(max(e2))
sciezkaOstPoz = ".//*[@id='"+ OstPozycja2+"']/td[5]"
PozNaF = driver.find_element_by_xpath(sciezkaOstPoz).text
NKampZPoz = PozNaF.split(":",1)[0]
tabela = tabela.replace(NazwaKampanii, "")
tabela = tabela.replace("\n"," ")
tabela =tabela.replace(" ", "")
PozNaF = PozNaF.replace(NazwaKampanii+":","")
PozNaF = PozNaF.replace("-","")
PozNaF = PozNaF.replace(" ","")
PozNaF = PozNaF.replace("\n","")
PozNaF = PozNaF.replace("szt.","")
print tabela
print PozNaF
NKampZPracy = NazwaKampanii
print NKampZPoz
print NKampZPracy
#TEST właciwy
self.assertEqual(tabela, PozNaF,"pozycje z pracy nie dodaly sie poprawnie")
self.assertEqual(NKampZPracy, NKampZPoz, "Nazwy Kampanii nie pokrywaja sie")
selectRow()
removeRow()
示例10: testExpectedConditionElementToBeSelected
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_selected [as 别名]
element.text
self.fail("Expected StaleReferenceException to have been thrown")
except StaleElementReferenceException, e:
pass
def testExpectedConditionElementToBeSelected(self):
self._loadPage("formPage")
element = self.driver.find_element_by_id('checky')
try:
WebDriverWait(self.driver, 0.7).until(EC.element_to_be_selected(element))
self.fail("Expected TimeoutException to have been thrown")
except TimeoutException, e:
pass
self.driver.execute_script("setTimeout(function(){document.getElementById('checky').checked = true}, 200)")
WebDriverWait(self.driver, 0.7).until(EC.element_to_be_selected(element))
self.assertTrue(element.is_selected())
def testExpectedConditionElementLocatedToBeSelected(self):
self._loadPage("formPage")
element = self.driver.find_element_by_id('checky')
try:
WebDriverWait(self.driver, 0.7).until(EC.element_located_to_be_selected((By.ID, 'checky')))
self.fail("Expected TimeoutException to have been thrown")
except TimeoutException, e:
pass
self.driver.execute_script("setTimeout(function(){document.getElementById('checky').checked = true}, 200)")
WebDriverWait(self.driver, 0.7).until(EC.element_located_to_be_selected((By.ID, 'checky')))
self.assertTrue(element.is_selected())
def testExpectedConditionElementSelectionStateToBe(self):
self._loadPage("formPage")
示例11: get_checked_asia
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_selected [as 别名]
def get_checked_asia(self):
asia = WebDriverWait(self.driver, 30, 0.1).until(
lambda d: d.find_element_by_xpath(self.ASIA)
)
return asia.is_selected()
示例12: search
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_selected [as 别名]
def search(browser, doi, logger):
'''
Searches one DOI on Scopus and returns a list of references.
@param doi: The DOI to search.
'''
try:
logger.log("Entering Scopus at url: " + SCOPUS_QUERY_URL)
browser.get(SCOPUS_QUERY_URL)
logger.log("Searching for DOI: " + doi)
search_field = browser.find_element_by_id("searchfield")
search_field.send_keys(DOI_FORMAT.format(doi))
search_button = browser.find_element_by_class_name("btnSearch")
search_button.click()
logger.log("Selecting all results from the query... Waiting on page load")
selectAll = WebDriverWait(browser, PAGE_TIMEOUT).until(EC.presence_of_element_located((By.ID, "allPageCheckBox")))
selectAll.click()
more_button = browser.find_element_by_id("moreLink")
more_button.click()
reference_viewer_anchor = browser.find_element_by_css_selector('#moreOptions > div > a.viewReferences')
reference_viewer_anchor.click()
logger.log("Selecting all the options from the references... Waiting on page load")
selectAll = browser.find_element_by_id("allPageCheckBox")
selectAll.click()
export_button = browser.find_element_by_id("export_results")
export_button.click()
logger.log("Waiting for export popup...")
format_select = WebDriverWait(browser, PAGE_TIMEOUT).until(EC.presence_of_element_located((By.ID, "custom-radioBtn-Text")))
format_select.click()
logger.log("Specifying PMID option only")
output_select_dropdown = browser.find_element_by_id('exportViewSelectBoxItContainer')
output_select_dropdown.click()
output_select = browser.find_element_by_css_selector('#exportViewSelectBoxItOptions li:last-child')
output_select.click()
uncheck = WebDriverWait(browser, PAGE_TIMEOUT).until(EC.presence_of_element_located((By.ID, "selectedCitationInformationItemsAll-Export")))
if uncheck.is_selected():
uncheck.click()
check = browser.find_element_by_id("selectedBibliographicalInformationItems-Export4")
if not check.is_selected():
check.click()
logger.log("Triggering the export process")
export_button = browser.find_element_by_id("exportTrigger")
export_button.click()
logger.log("Switching browser windows")
browser.switch_to_window(browser.window_handles[-1])
pre = WebDriverWait(browser, 200).until(EC.presence_of_element_located((By.TAG_NAME, "pre")))
text = pre.text.encode('utf-8')
logger.log(text)
return text
except Exception as e:
logger.log(str(e), "ERROR")
return ""