本文整理汇总了Python中selenium.webdriver.support.ui.Select类的典型用法代码示例。如果您正苦于以下问题:Python Select类的具体用法?Python Select怎么用?Python Select使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Select类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cannot_compute_zero_features
def test_cannot_compute_zero_features(driver, project, dataset):
driver.get('/')
driver.refresh()
proj_select = Select(driver.find_element_by_css_selector('[name=project]'))
proj_select.select_by_value(str(project.id))
driver.find_element_by_id('react-tabs-4').click()
driver.find_element_by_partial_link_text('Compute New Features').click()
driver.find_element_by_xpath("//li[contains(text(),'General')]").click()
amplitude = driver.find_element_by_css_selector('[name=amplitude]')
assert amplitude.get_attribute('value') == 'true'
driver.find_element_by_partial_link_text('Check/Uncheck All').click()
time.sleep(0.1)
assert amplitude.get_attribute('value') == 'false'
driver.find_element_by_xpath("//li[contains(.,'Cadence')]").click()
n_epochs = driver.find_element_by_css_selector('[name=n_epochs]')
assert n_epochs.get_attribute('value') == 'true'
driver.find_element_by_partial_link_text('Check/Uncheck All').click()
time.sleep(0.1)
assert n_epochs.get_attribute('value') == 'false'
driver.find_element_by_xpath("//li[contains(.,'Lomb-Scargle')]").click()
driver.find_element_by_partial_link_text('Check/Uncheck All').click()
assert driver.find_element_by_css_selector(
'[name=fold2P_slope_10percentile]').get_attribute('value') == 'false'
featureset_name = driver.find_element_by_css_selector('[name=featuresetName]')
featureset_name.send_keys(test_featureset_name)
driver.find_element_by_class_name('btn-primary').click()
driver.wait_for_xpath(
"//div[contains(.,'At least one feature must be selected')]")
示例2: getHtml
def getHtml(word,driver):
driver.get('http://www.shufazidian.com')
elem = driver.find_element_by_name('wd')
select = Select(driver.find_element_by_name('sort'))
select.select_by_value('9')
# print('1, ', ctime())
elem.send_keys(word)
# wait = WebDriverWait(driver,5)
elem.send_keys(Keys.RETURN)
# driver.implicitly_wait(5)
# try:
# element = wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,'.mbpho')))
# print('3, ',ctime())
# except Exception,e:
# print(e)
# print('4, ', ctime())
delay = 7 # seconds
try:
WebDriverWait(driver, delay).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,'.mbpho')))
except TimeoutException:
# print >>f , "TimeoutException Loading took too much time!"
pass
time.sleep(5)
return driver.page_source
示例3: makeselection
def makeselection():
month = browser.find_element_by_xpath(".//a[contains(@onclick, 'jmpto1605')]")
month.send_keys("\n")
time.sleep(5) # delays for 5 seconds
sectionDatesOfStay = browser.find_element_by_id('sectionDatesOfStay')
containerDatesOfStay = sectionDatesOfStay.find_element_by_id('containerDatesOfStay')
calCell = containerDatesOfStay.find_element_by_class_name('calCell')
cal1 = calCell.find_element_by_id('cal1')
calTable1605 = cal1.find_element_by_id('calTable1605')
# Select May 28 as the arrival day
date_28 = calTable1605.find_element_by_id('160528')
date_28.send_keys("\n")
time.sleep(5) # delays for 5 seconds
# Select May 29 as the departure day
date_29 = calTable1605.find_element_by_id('160529')
date_29.send_keys("\n")
time.sleep(5) # delays for 5 seconds
# Select the adults number
frmNumAdults = browser.find_element_by_id('frmNumAdults')
adultNo = Select(frmNumAdults)
adultNo.select_by_visible_text('2')
# Check the room status
time.sleep(5)
suiteTypes = browser.find_element_by_id('suiteTypes')
sendemail()
示例4: test_new_duplicates_project_name
def test_new_duplicates_project_name(self):
"""
Should not be able to create a new project whose name is the same
as an existing project
"""
project_name = "dupproject"
Project.objects.create_project(name=project_name,
release=self.release)
url = reverse('newproject')
self.get(url)
self.enter_text('#new-project-name', project_name)
select = Select(self.find('#projectversion'))
select.select_by_value(str(self.release.pk))
element = self.wait_until_visible('#hint-error-project-name')
self.assertTrue(("Project names must be unique" in element.text),
"Did not find unique project name error message")
# Try and click it anyway, if it submits we'll have a new project in
# the db and assert then
self.click("#create-project-button")
self.assertTrue(
(Project.objects.filter(name=project_name).count() == 1),
"New project not found in database")
示例5: walkProd
def walkProd():
global driver, prevTrail
try:
# click overlay advertisement popup left button "No Thanks"
try:
driver.find_element_by_css_selector("a.btn.close.fl-left").\
click()
except (NoSuchElementException):
pass
zpath = ('#ctl00_ctl00_ctl00_mainContent_localizedContent_bodyCenter'+
'_adsPanel_lbProduct')
waitTextChanged(zpath)
curSel = Select(css(zpath))
numProds = len(curSel.options)
ulog("numProds=%d"%numProds)
startIdx = getStartIdx()
for idx in range(startIdx, numProds):
curSel = Select(css(zpath))
ulog("idx=%s"%idx)
ulog('select "%s"'%curSel.options[idx].text)
curSel.select_by_index(idx)
prevTrail+=[idx]
while True:
ret = walkFile()
if ret != TRY_AGAIN:
break
if ret== PROC_GIVE_UP:
ulog('"%s" is GIVE UP'% curSel.options[idx].text)
prevTrail.pop()
return PROC_OK
except Exception as ex:
traceback.print_exc(); ipdb.set_trace()
driver.save_screenshot('netgear_exc.png')
示例6: select_state
def select_state(self, state):
select = Select(self.driver.find_element(*ShippingPageLocators.STATE_DROPDOWN))
if state==None:
state_number = randint(0,49)
select.select_by_index(state_number)
else:
select.select_by_visible_text(state)
示例7: submit_form
def submit_form(self, form, data, clear=True, submit=True, wait=True):
for k, v in data.items():
input_field = form.find_element_by_name(k)
if input_field.tag_name in ('input', 'textarea'):
field_type = input_field.get_attribute('type')
if field_type == 'radio':
radio_button = form.find_element_by_css_selector(
"input[type=radio][name={}][value='{}']".format(
k, v
)
)
radio_button.click()
elif field_type == 'checkbox':
checkbox_button = form.find_element_by_css_selector(
'input[type=checkbox][name={}]'.format(k)
)
if v and not checkbox_button.is_selected():
checkbox_button.click()
elif not v and checkbox_button.is_selected():
checkbox_button.click()
elif clear and input_field.get_attribute('value'):
input_field.clear()
input_field.send_keys(v)
elif input_field.tag_name == 'select':
select_field = Select(input_field)
select_field.select_by_value(v)
if submit:
submit_btn = form.find_element_by_xpath(
'.//button[@type="submit"]')
submit_btn.click()
if wait:
self.wait_for_page_load()
示例8: _test_fxa_signup
def _test_fxa_signup(self):
'''FullFlow1:create, signout - %s %s %s''' % \
(self.os, self.br, self.version)
self.driver.get(FXA_SIGNUP)
time.sleep(2)
assert 'Create' in self.driver.title
username = self.driver.find_element_by_css_selector(input_email)
username.send_keys(self.fxa_new_user)
time.sleep(2)
pw = self.driver.find_element_by_css_selector(input_password)
pw.send_keys(fxa_password)
selectBox = Select(self.driver.find_element_by_id(coppa_locator))
time.sleep(2)
selectBox.select_by_visible_text("1991")
self.driver.find_element_by_id(btn_submit).click()
self.wait_page_load(FXA_SIGNUP)
assert 'Confirm your account' in self.driver.title
# verify restmail user
time.sleep(4)
restmail_link = getRestmailLink(self.fxa_new_user)
self.driver.get(restmail_link)
time.sleep(2)
assert 'verified' in self.driver.title
示例9: test_volvox
def test_volvox():
format_volvox()
browser = webdriver.Firefox() # Get local session of firefox
browser.get("file://%s/index.html?data=sample_data/json/volvox" % os.getcwd() ) # Load page
# select "ctgA from the dropdown
refseq_selector = Select(browser.find_element_by_id('chrom'))
refseq_selector.select_by_value('ctgA')
# check a good browser title
assert "ctgA" in browser.title, "browser title is actually %s" % browser.title
tabs = browser.find_elements_by_xpath( '//div[@class="browsingTab"]' )
for t in tabs:
t.click()
time.sleep(1)
t.click()
time.sleep(0.5)
assert_no_js_errors(browser)
# do a test where we search for a certain gene using the search box
search_f15(browser)
assert_no_js_errors(browser)
# test scrolling, make sure we get no js errors
scroll(browser)
# test dragging in and displaying the wiggle track
wiggle(browser)
browser.close()
pass;
示例10: bulkCreate
def bulkCreate(self):
self.log.write("namepefix id" +self.guestNamePefix)
self.browser.find_element_by_xpath("//*[@id='guestName']").send_keys(self.guestNamePefix)
self.browser.find_element_by_xpath("//*[@id='userProfile']").clear()
self.log.write("guestnumber is"+self.guestNumber)
self.browser.find_element_by_xpath("//*[@id='userProfile']").send_keys(self.guestNumber)
self.log.write("select guest type,guest type is"+self.guestType)
select = Select(self.browser.find_element_by_xpath("//*[@name='authType']"))
select.select_by_visible_text(self.guestType)
time.sleep(2)
# //*[@id="J-create"]
self.log.write("click 'create'")
self.browser.find_element_by_xpath("//a[@id='J-create']").click()
time.sleep(2)
self.guestinfo.append("Wi-Fi Network:")
self.guestinfo.append(self.browser.find_element_by_xpath("//form[@id='guest-two-form']/fieldset/table/tbody/tr/td[2]/p").text)
self.guestinfo.append("Prefix for Guest Names:")
self.guestinfo.append(self.browser.find_element_by_xpath("//form[@id='guest-two-form']/fieldset/table/tbody/tr[2]/td[2]/p").text)
self.guestinfo.append("Number of Guests:")
self.guestinfo.append(self.browser.find_element_by_xpath("//form[@id='guest-two-form']/fieldset/table/tbody/tr[3]/td[2]/p").text)
self.guestinfo.append("Access Duration:")
self.guestinfo.append(self.browser.find_element_by_xpath("//form[@id='guest-two-form']/fieldset/table/tbody/tr[4]/td[2]/p").text)
self.browser.find_element_by_xpath("//*[@id='deliver-name']").send_keys(self.email)
self.log.write("click 'comfirm'")
self.browser.find_element_by_xpath("/html/body/div/div[2]/div[2]/div[2]/div/form/fieldset[2]/table/tbody/tr[3]/td[2]/p/a").click()
time.sleep(2)
示例11: createGuest
def createGuest(self):
# self.gotoCreateGuest(self)
# self.browser.find_element_by_xpath("/html/body/div/div[2]/div[2]/div/div[2]/div/div/p[2]/a").click()
time.sleep(2)
self.log.write("guetname is "+self.guestName)
self.browser.find_element_by_xpath("//*[@id='guestName']").send_keys(self.guestName)
self.log.write("organization is" +self.organization)
self.browser.find_element_by_xpath("//*[@id='organization']").send_keys(self.organization)
self.log.write("purpose is"+self.purposeOfVisit)
self.browser.find_element_by_xpath("//*[@id='visitPurpose']").send_keys(self.purposeOfVisit)
self.log.write("email is "+self.email)
self.browser.find_element_by_xpath("//*[@id='email']").send_keys(self.email)
self.log.write("phone is" +self.phone)
self.browser.find_element_by_xpath("//*[@id='phoneNumber']").send_keys(self.phone)
self.log.write("the type of logname is"+self.loginName)
self.browser.find_element_by_xpath("//input[@value='"+self.loginName+"']").click()
# logname:email,phone,name
self.log.write("select guesttype" +self.guestType)
select = Select(self.browser.find_element_by_xpath("//*[@id='J-guest-type']"))
select.select_by_visible_text(self.guestType)
self.log.write("click 'create'")
self.browser.find_element_by_xpath("//*[@id='J-next']").click()
# guestSsid=self.browser.find_elenment_by_xpath("//form[@id='new-gt-form']/fieldset[3]/table/tbody/tr[2]/td[2]/p[2]/span").text
# self.browser.find_element_by_xpath("//form[@id='new-gt-form']/fieldset[3]/table/tbody/tr[4]/td[2]/p/a").click()
# self.guestloginName=self.browser.find_element_by_xpath("/html/body/div[6]/div/div/form/fieldset/table/tbody/tr[2]/td[2]/p").text
# self.guestpasswd=self.browser.find_element_by_xpath("/html/body/div[6]/div/div/form/fieldset/table/tbody/tr[3]/td[2]/p").text
# self.accessTime=self.browser.find_element_by_xpath("/html/body/div[6]/div/div/form/fieldset/table/tbody/tr[4]/td[2]/p").text
# self.sendEmail=self.browser.find_element_by_path("//*[@id='deliver-name']").text
time.sleep(2)
self.log.write("click 'confirm'")
self.browser.find_element_by_xpath("/html/body/div/div[2]/div[2]/div[2]/div/form/fieldset[2]/table/tbody/tr[3]/td[2]/p/a").click()
# self.browser.find_element_by_xpath("/html/body/div[6]/div/div/form/fieldset[2]/table/tbody/tr[3]/td[2]/p/a").click()
time.sleep(2)
示例12: select
def select(self, selector, value):
from selenium.webdriver.support.ui import Select
elem = self.selenium.find_element_by_css_selector(selector)
select = Select(elem)
select.select_by_visible_text(value)
示例13: create_csv
def create_csv(year,month):
path = os.getcwd()+os.sep+"temp"
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2) # custom location
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', path)
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv')
driver = webdriver.Firefox(profile)
try:
driver.get("https://www.ura.gov.sg/realEstateIIWeb/price/search.action")
driver.implicitly_wait(5)
select_year = Select(driver.find_element_by_name('yearSelect'))
onchange_null = "document.getElementById('yearSelect').onchange='';document.getElementById('monthSelect').onchange='';"
clear_month = "$('#monthSelect').empty();"
append_month = "$('#monthSelect').append(\"<option selected='selected' value="+str(month)+">"+str(month)+"</option>\");"
driver.execute_script(clear_month)
driver.execute_script(onchange_null)
driver.execute_script(append_month)
select_year.select_by_visible_text(year)
driver.execute_script("submitViewAll()")
driver.implicitly_wait(5)
driver.get("https://www.ura.gov.sg/realEstateIIWeb/price/submitExcelResults.action")
print(year,month)
driver.close()
except:
print("Logging missed values")
print(year,month)
print(sys.exc_info())
log.append([year,month])
driver.implicitly_wait(10)
示例14: test_check_uncheck_features
def test_check_uncheck_features(driver, project, dataset):
driver.get('/')
driver.refresh()
proj_select = Select(driver.find_element_by_css_selector('[name=project]'))
proj_select.select_by_value(str(project.id))
driver.find_element_by_id('react-tabs-4').click()
driver.find_element_by_partial_link_text('Compute New Features').click()
driver.find_element_by_xpath("//li[contains(text(),'General')]").click()
amplitude = driver.find_element_by_css_selector('[name=amplitude]')
assert amplitude.get_attribute('value') == 'true'
driver.find_element_by_partial_link_text('Check/Uncheck All').click()
time.sleep(0.3)
assert amplitude.get_attribute('value') == 'false'
driver.find_element_by_partial_link_text('Check/Uncheck All').click()
time.sleep(0.1)
assert amplitude.get_attribute('value') == 'true'
driver.find_element_by_xpath("//li[contains(.,'Cadence')]").click()
n_epochs = driver.find_element_by_css_selector('[name=n_epochs]')
assert n_epochs.get_attribute('value') == 'true'
driver.find_element_by_partial_link_text('Check/Uncheck All').click()
time.sleep(0.1)
assert n_epochs.get_attribute('value') == 'false'
driver.find_element_by_xpath("//li[contains(.,'Lomb-Scargle')]").click()
driver.find_element_by_partial_link_text('Check/Uncheck All').click()
assert driver.find_element_by_css_selector(
'[name=fold2P_slope_10percentile]').get_attribute('value') == 'false'
示例15: select_current_climate_layers
def select_current_climate_layers(self, resolution, string):
# select the correct resolution filter
select = Select(self.driver.find_element_by_name("form.widgets.resolution:list"))
select.select_by_visible_text(resolution)
# Yes, there is a type here, but that's how it is on the backend
path_string = "(//tr[@data-friendlyname='collapbsable_climatelayer_" + string + "'])"
self.driver.find_element_by_xpath(path_string).click()