本文整理汇总了Python中selenium.webdriver.support.select.Select.select_by_visible_text方法的典型用法代码示例。如果您正苦于以下问题:Python Select.select_by_visible_text方法的具体用法?Python Select.select_by_visible_text怎么用?Python Select.select_by_visible_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.select.Select
的用法示例。
在下文中一共展示了Select.select_by_visible_text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_in_group
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def add_in_group(self, groupname):
wd = self.app.wd
self.app.open_home_page()
my_select = Select(wd.find_element_by_xpath("//div[@id='content']/form/select[1]"))
my_select.select_by_visible_text(groupname)
self.contact_cache = None
示例2: select_report
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def select_report(self, report_name):
'''
Select the report type from the drop down
and wait for the page to reload
'''
report_dropdown = self.find_element(*self._report_select_locator)
select = Select(report_dropdown)
select.select_by_visible_text(report_name)
if 'Top Crashers' == report_name:
from pages.crash_stats_top_crashers_page import CrashStatsTopCrashers
page = CrashStatsTopCrashers(self.selenium, self.page.base_url)
return page.wait_for_page_to_load()
elif 'Top Crashers by TopSite' == report_name:
from pages.crash_stats_top_crashers_by_site_page import CrashStatsTopCrashersBySite
page = CrashStatsTopCrashersBySite(self.selenium, self.page.base_url)
return page.wait_for_page_to_load()
elif 'Crashes per Day' == report_name:
from pages.crash_stats_per_day import CrashStatsPerDay
page = CrashStatsPerDay(self.selenium, self.page.base_url)
return page.wait_for_page_to_load()
elif 'Nightly Builds' == report_name:
from pages.crash_stats_nightly_builds_page import CrashStatsNightlyBuilds
page = CrashStatsNightlyBuilds(self.selenium, self.page.base_url)
return page.wait_for_page_to_load()
示例3: select_option_with_text
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def select_option_with_text(self, select_locator, select_rule, visible_text=None, value=None, wait_timeout=-1):
"""Select the write option in a <select> element
:param select_locator: the engine to process the rule
:type select_locator: selenium.webdriver.common.by.By
:param select_rule: the rule the <select> element must match
:type select_rule: str
:param visible_text: the text inside <option> tag. Must be used only if value is None
:type visible_text: str
:param value: the text inside value attribute for <option> tag. Must be used only if visible_text is None
:type value: str
:param wait_timeout: Number of second that we will poll the DOM. Once this is over, a TimeoutException is raised\
if wait_timeout is negative, no wait will be processed
:type wait_timeout: int
:raises TimeoutException: when wait_timeout is provided and the select element is not found before timeout
:raises NoSuchElementException: when Select element is not found our there no <option> child matching your \
requirements
:raises WebDriverException: when element exist but can't be accessed or when your driver failed to process the \
selection action
"""
if value is not None and visible_text is not None:
raise ValueError("Can't select by visible text AND value")
if value is None and visible_text is None:
raise ValueError("You must select by value OR by visible text")
if wait_timeout < 0:
select = Select(self.driver.find_element(by=select_locator, value=select_rule))
else:
element = WebDriverWait(self.driver, wait_timeout).until(
EC.element_to_be_clickable((select_locator, select_rule))
)
select = Select(element)
if visible_text is not None:
select.select_by_visible_text(visible_text)
if value is not None:
select.select_by_value(value)
示例4: select_report_preview_option
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def select_report_preview_option(self, report_name):
"""
Selects the report preview option.
:param report_name: Type of report to select.
"""
select = Select(self._driver.find_element(*self._report_preview_combobox))
select.select_by_visible_text(report_name)
示例5: create_run
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def create_run(self, name='Test Run', product_version='Test Product Test Version', desc='This is a test run', start_date='2011-01-01', end_date='2012-12-31', suite_list=None, series_run=False):
dt_string = datetime.utcnow().isoformat()
run = {}
run['name'] = u'%(name)s %(dt_string)s' % {'name': name, 'dt_string': dt_string}
run['desc'] = u'%(desc)s created on %(dt_string)s' % {'desc': desc, 'dt_string': dt_string}
run['series'] = series_run
run['manage_locator'] = (self._run_manage_locator[0], self._run_manage_locator[1] % {'run_name': run['name']})
run['homepage_locator'] = (self._run_homepage_locator[0], self._run_homepage_locator[1] % {'run_name': run['name']})
run['run_tests_locator'] = self._run_tests_button_locator
name_field = self.selenium.find_element(*self._name_locator)
name_field.send_keys(run['name'])
series_element = self.selenium.find_element(*self._series_run_locator)
if series_element.is_selected():
if not series_run:
series_element.click()
else:
if series_run:
series_element.click()
product_version_select = Select(self.selenium.find_element(*self._product_version_select_locator))
product_version_select.select_by_visible_text(product_version)
self.selenium.find_element(*self._description_locator).send_keys(run['desc'])
self.type_in_element(self._start_date_locator, start_date)
self.selenium.find_element(*self._end_date_locator).send_keys(end_date)
if suite_list:
self.multiselect_widget.include_items(suite_list)
self.selenium.find_element(*self._submit_locator).click()
return run
示例6: remove_from_group
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def remove_from_group(self, contact, group):
wd = self.app.wd
self.load_home_page()
select = Select(wd.find_element_by_name("group"))
select.select_by_visible_text(group.name.strip())
self.select_by_id(contact.id)
wd.find_element_by_name("remove").click()
示例7: UsersReportCMS
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
class UsersReportCMS(ReportsBaseCMS):
organization_dropdown_id = "id_team__organization__name"
def __init__(self, driver, wait, report=None):
self.driver = driver
self.wait = wait
if(report == None):
self.driver.get(ServerRelated().serverToBeTested() + "admin/reports/user-report/")
self.groupByField = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_groupby")))
self.contentProjectDropdown = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_team__organization__contentproject__title")))
def selectGroupByField(self, option):
self.groupByField.select_by_visible_text(option)
def selectOrganizationByValue(self, text):
organization = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_team__organization__name")))
organization.select_by_visible_text(text)
def clickGetResultsButton(self):
self.clickGetResults()
return UsersReportCMS(self.driver, self.wait, "report")
def getContentProjectOptions(self):
options = self.getOptionsTextInCombobox(self.contentProjectDropdown)
options.remove("---------")
return options
示例8: get_contact_in_group
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def get_contact_in_group(self,group_name):
if self.contact_cache is None:
wd = self.app.wd
self.open_home_form()
# установим фильтр #выбор имени группы
#my_select = Select(wd.find_element_by_xpath("//div[@id='content']/form/select[5]"))
my_select = Select(wd.find_element_by_xpath("/html/body/div[@id='container']/div[@id='content']/form[@id='right']/select"))
my_select.select_by_visible_text(group_name)
self.contact_cache=[]
# бежим по таблице замисывая "строки" в массив
rows = wd.find_elements_by_xpath("//div[1]/div[4]/form[2]/table/tbody/tr[@name='entry']")
for elements in rows:
#теперь пробежим по столбцам текущего tr из цикла
column = elements.find_elements_by_tag_name("td")
firstname = column[2].text
lastname = column[1].text
id = elements.find_element_by_name("selected[]").get_attribute("value")
all_phones = column[5].text
all_emails = column[4].text
self.contact_cache.append(Contact(lastname=lastname,firstname=firstname,id=id,
all_phones_from_home_page = all_phones,
# home=all_phones[0],
# mobile=all_phones[1],
# work=all_phones[2],
# fax=all_phones[3],
all_emails_from_home_page = all_emails,
# email1=all_emails[0],
# email2=all_emails[1],
# email3=all_emails[2]
)
)
return list(self.contact_cache)
示例9: add_a_new_facility
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def add_a_new_facility(self, facility):
self.go_to_facilities()
self.wait.until(EC.title_is('Facilities'))
link = self.wait.until(EC.presence_of_element_located(
(By.ID, 'id_add_new_facility_link')))
link.click()
self.wait.until(EC.title_is('Add New Facility'))
inputbox = self.wait.until(
EC.presence_of_element_located((By.ID, 'id_facility_name')))
inputbox.send_keys(facility.name)
self.browser.find_element_by_xpath(
'//select[@id="id_facility_type"]/option[text()="%s"]' %
facility.type).click()
inputbox = self.wait.until(
EC.presence_of_element_located((By.ID, 'id_facility_status')))
inputbox.send_keys(facility.status)
if facility.area:
select = Select(self.browser.find_element_by_id('id_facility_area'))
select.select_by_visible_text(unicode(facility.area))
if facility.json:
inputbox = self.wait.until(
EC.presence_of_element_located((By.ID, 'id_json')))
inputbox.send_keys(facility.json)
submit = self.browser.find_element_by_id('id_submit_button')
submit.click()
self.wait.until(EC.title_is('Facilities'))
示例10: type_incall_destination
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def type_incall_destination(destination_type, destination_name):
type_select = Select(world.browser.find_element_by_id('it-dialaction-answer-actiontype'))
type_select.select_by_visible_text(destination_type)
destination_select = Select(world.browser.find_element_by_id(DESTINATION_ELEMENT_MAP[destination_type]))
for option in destination_select.options:
if destination_name in option.text:
destination_select.select_by_visible_text(option.text)
示例11: create_product
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def create_product(self, name="Test Product", version="Test Version", desc="This is a test product", profile=None):
dt_string = datetime.utcnow().isoformat()
product = {}
product["name"] = u"%(name)s %(dt_string)s" % {"name": name, "dt_string": dt_string}
product["desc"] = u"%(desc)s created on %(dt_string)s" % {"desc": desc, "dt_string": dt_string}
product["locator"] = (self._product_locator[0], self._product_locator[1] % {"product_name": product["name"]})
product["version"] = {}
product["version"]["name"] = u"%(version)s %(dt_string)s" % {"version": version, "dt_string": dt_string}
product["version"]["manage_locator"] = (
self._version_manage_locator[0],
self._version_manage_locator[1]
% {"product_name": product["name"], "version_name": product["version"]["name"]},
)
product["version"]["homepage_locator"] = (
self._version_homepage_locator[0],
self._version_homepage_locator[1]
% {"product_name": product["name"], "version_name": product["version"]["name"]},
)
self.selenium.find_element(*self._name_locator).send_keys(product["name"])
self.selenium.find_element(*self._version_locator).send_keys(product["version"]["name"])
self.selenium.find_element(*self._description_locator).send_keys(product["desc"])
if profile:
profile_select = Select(self.selenium.find_element(*self._profile_locator))
profile_select.select_by_visible_text(profile)
self.selenium.find_element(*self._submit_locator).click()
return product
示例12: select_multi
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def select_multi(context, key, data):
input_selector = (By.NAME, key)
input_el = context.browser.find_element(*input_selector)
select = Select(input_el)
for item in data:
select.select_by_visible_text(item)
return [opt.text for opt in select.all_selected_options]
示例13: test_load_form
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def test_load_form(self):
fld = make_field(
self.registry.fields[2],
self.registry.fields[2].ops[1],
json.dumps([2000, 2010]))
SearchForm.objects.create(
name="lol",
owner=User.objects.create(username='foo', password='bar'),
public=True,
data=json.dumps({"form_data": [None, fld]}))
self.page.load_form_by_name('lol')
field = self.page.extract_field_data(
self.page.find_element_by_jquery("#field-0"))
self.assertEquals(
field['selected'], unicode(self.registry.fields[2].label))
self.assertEquals(field['value'][0], 2000)
self.assertEquals(field['value'][1], 2010)
# Przetestuj, czy po ANULOWANIU select wróci do pierwotnej wartości
select = Select(
self.page.find_element_by_jquery("#formsSelector"))
select.select_by_visible_text('lol')
self.page.switch_to_alert().dismiss()
self.assertEquals(
self.page.find_element_by_jquery("#formsSelector").val(), "")
示例14: add_from_homepage_in_group
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def add_from_homepage_in_group(self, id, groupname):
wd = self.app.wd
self.app.open_home_page()
wd.find_element_by_css_selector("input[value='%s']" % id).click()
my_select = Select(wd.find_element_by_xpath("//div[@id='content']/form/select[1]"))
my_select.select_by_visible_text(groupname)
self.contact_cache = None
示例15: select_report
# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_visible_text [as 别名]
def select_report(self, report_name):
"""
Select the report type from the drop down
and wait for the page to reload
"""
report_dropdown = self.selenium.find_element(*self._report_select_locator)
select = Select(report_dropdown)
select.select_by_visible_text(report_name)
if "Top Crashers" == report_name:
from pages.crash_stats_top_crashers_page import CrashStatsTopCrashers
return CrashStatsTopCrashers(self.testsetup)
elif "Top Crashers by TopSite" == report_name:
from pages.crash_stats_top_crashers_by_site_page import CrashStatsTopCrashersBySite
return CrashStatsTopCrashersBySite(self.testsetup)
elif "Crashes per User" == report_name:
from pages.crash_stats_per_active_daily_user_page import CrashStatsPerActiveDailyUser
return CrashStatsPerActiveDailyUser(self.testsetup)
elif "Nightly Builds" == report_name:
from pages.crash_stats_nightly_builds_page import CrashStatsNightlyBuilds
return CrashStatsNightlyBuilds(self.testsetup)
elif "Top Changers" == report_name:
from pages.crash_stats_top_changers_page import CrashStatsTopChangers
return CrashStatsTopChangers(self.testsetup)