当前位置: 首页>>代码示例>>Python>>正文


Python select.Select类代码示例

本文整理汇总了Python中selenium.webdriver.support.select.Select的典型用法代码示例。如果您正苦于以下问题:Python Select类的具体用法?Python Select怎么用?Python Select使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Select类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: EditAddOrganiztionPageCMS

class EditAddOrganiztionPageCMS(BasePageCMS):
     
    def __init__(self, driver, wait):
        self.driver = driver
        self.wait = wait
        self.name = self.wait.until(lambda driver : driver.find_element_by_id("id_name"))
        self.parent = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_parent")))
        self.lmSite = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_lmsite")))
    
    def typeName(self, name):
        self.name.send_keys(name)
        
    def selectParent(self, parent):
        self.parent.select_by_visible_text(parent)
    
    def selectLmSite(self, site):
        self.lmSite.select_by_visible_text(site)
    
    def clickSaveAndContinueEditingButton(self):
        self.clickSaveAndContinueEditing()
        return EditAddOrganiztionPageCMS(self.driver, self.wait)
    
    def getName(self):
        return self.name.get_attribute("value")
    
    def getSelectedParent(self):
        return self.parent.first_selected_option.text
    
    def getSelectedLmSite(self):
        return self.lmSite.first_selected_option.text
    
    def clickObjectPermissions(self):
        self.clickOnLink("Object permissions")
        return OrganizationObjectPermissionsCMS(self.driver, self.wait)
开发者ID:cbalea,项目名称:LM-AUTOMATION,代码行数:34,代码来源:organizations_page_cms.py

示例2: chooseSelectElement

 def chooseSelectElement(self, fieldName, fieldText):
     """
     Chooses one of the elements in a select list, by its visible text
     """
     select = Select(self.driver.find_element_by_name(fieldName));
     #select.deselect_all()
     select.select_by_visible_text(fieldText)
开发者ID:Skynet2-0,项目名称:Skynet2.0,代码行数:7,代码来源:VPSBuyer.py

示例3: select_option_by_value

def select_option_by_value(browser_query, value):
    """
    Selects a html select element by matching value attribute
    """
    select = Select(browser_query.first.results[0])
    select.select_by_value(value)

    def options_selected():
        """
        Returns True if all options in select element where value attribute
        matches `value`. if any option is not selected then returns False
        and select it. if value is not an option choice then it returns False.
        """
        all_options_selected = True
        has_option = False
        for opt in select.options:
            if opt.get_attribute('value') == value:
                has_option = True
                if not opt.is_selected():
                    all_options_selected = False
                    opt.click()
        # if value is not an option choice then it should return false
        if all_options_selected and not has_option:
            all_options_selected = False
        return all_options_selected

    # Make sure specified option is actually selected
    EmptyPromise(options_selected, "Option is selected").fulfill()
开发者ID:chauhanhardik,项目名称:populo,代码行数:28,代码来源:helpers.py

示例4: DashboardPageCMS

class DashboardPageCMS(BasePageCMS):
    
    def __init__(self, driver, wait, noPageLoad=None):
        self.driver = driver
        self.wait = wait
        if(noPageLoad==None):
            self.driver.get(ServerRelated().serverToBeTested() + "admin/cms/contentproject/dashboard/")
        self.uploadDropdown = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_upload_media")))
        self.createDropdown = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_create_content")))
    
    def selectUploadMediaByText(self, media):
        self.uploadDropdown.select_by_visible_text(media)
    
    def selectCreateUser(self):
        self.createDropdown.select_by_visible_text("User")
        return OrganizationUsersPageCMS(self.driver, self.wait)
    
    def getNumberOfVisibleContentProjects(self):
        self.contProjects = self.wait.until(lambda driver : driver.find_elements_by_xpath("//li[contains(text(),'Content Projects')]/ul/li"))
        return len(self.contProjects)
    
    def clickModifyStationModule(self):
        self.clickOnLink("Modify Station Module")
        return EditAddStationModulePageCMS(self.driver, self.wait)

    def clickUsersLink(self):
        self.clickOnLink("Users")
        return OrganizationUsersPageCMS(self.driver, self.wait)

    def getTitlesFromDashboard(self):
        dashboardTitles = self.wait.until(lambda driver : driver.find_elements_by_xpath("//tbody[@id='content_items_table_body']/tr/td[@class='original']"))
        titles = []
        for element in dashboardTitles:
            titles.append(element.text)
        return titles
开发者ID:cbalea,项目名称:LM-AUTOMATION,代码行数:35,代码来源:dashboard_page_cms.py

示例5: downloadChunk

def downloadChunk( link, browser, rFrom, rTo, i ):
    try :
        close = browser.find_element_by_xpath("//a[@class='quickoutput-cancel-action']")  #close previous download box
        close.click()
    except :
        pass

    fFrom = str(rFrom)
    rTo = str(rTo)

    browser.execute_script("window.scrollTo(0, 0);")
    #time.sleep(1)
    browser.find_element_by_xpath("//div[@id='s2id_saveToMenu']//b").click()  #save to arrow

    if i == 1:
        browser.find_element_by_id('select2-result-label-12').click()  #save to other formats
    else :
        browser.find_element_by_id('select2-chosen-1').click()  #save to other formats

    browser.find_element_by_id('numberOfRecordsRange').click()  #select records range
    browser.find_element_by_id('markFrom').click()  #click on from box
    browser.find_element_by_id('markFrom').send_keys(fFrom)  #enter keys in from box
    browser.find_element_by_id('markTo').click()  #click on to box
    browser.find_element_by_id('markTo').send_keys(rTo)  #enter keys in to box

    dropdown = browser.find_element_by_id('bib_fields')  #find fields dropdown
    select_box = Select(dropdown)
    select_box.select_by_index(3)  #select option 3 (all records and refs)

    browser.find_element_by_xpath("//span[@class='quickoutput-action']").click()  #click send
开发者ID:mcallaghan,项目名称:scrapeWoS,代码行数:30,代码来源:__init__.py

示例6: select_version_by_index

 def select_version_by_index(self, index):
     '''
         Select the version of the application you want to report on
     '''
     version_dropdown = self.find_element(*self._all_versions_locator)
     select = Select(version_dropdown)
     select.select_by_index(index)
开发者ID:stephendonner,项目名称:socorro,代码行数:7,代码来源:base_page.py

示例7: select_product

 def select_product(self, application):
     '''
         Select the Mozilla Product you want to report on
     '''
     element = self.find_element(*self._product_select_locator)
     select = Select(element)
     return select.select_by_visible_text(application)
开发者ID:stephendonner,项目名称:socorro,代码行数:7,代码来源:base_page.py

示例8: select_from_list

 def select_from_list(self, element=None, value=None):
     locator, _type = element
     if not self.wait_element(element):
         allure.attach('screenshot', self.driver.get_screenshot_as_png(), type=AttachmentType.PNG)
         pytest.fail("element {} not found".format(locator))
     select = Select(self.driver.find_element(by=_type, value=locator))
     select.select_by_value(value)
开发者ID:vitekes,项目名称:quotes,代码行数:7,代码来源:WebDriverExt.py

示例9: add_to_group

 def add_to_group(self, contact, group):
     wd = self.app.wd
     self.load_home_page()
     self.select_by_id(contact.id)
     select = Select(wd.find_element_by_name("to_group"))
     select.select_by_visible_text(group.name.strip())
     wd.find_element_by_name("add").click()
开发者ID:arseny-tsyro,项目名称:python_training,代码行数:7,代码来源:contact.py

示例10: fill_payments_form

def fill_payments_form(payments_form, 
                       first_name, 
                       last_name, 
                       gender, 
                       phone_number, 
                       email_address, 
#                        birthday_date
                       ):
    """
    Function for fill up payments form.
    Params: 
    # first_name, 
    # last_name, 
    # gender - value "mrs" means female and "mr" means male, 
    # phone_number, 
    # email_address.
    """
#      birthday_date
#     """
    _genders = [u"mrs", u"mr"]
    if not gender in _genders:
        raise Exception('Bad gender value %s - please choose from %s' % (gender, _genders))
    payments_form.find_element_by_id("bookFlight_paxes_1_name").send_keys(first_name)
    payments_form.find_element_by_id("bookFlight_paxes_1_surname").send_keys(last_name)
    gender_select = Select(payments_form.find_element_by_id("bookFlight_paxes_1_title"))
    gender_select.select_by_value(gender)
    payments_form.find_element_by_id("bookFlight_contactDetails_phoneNumber_phoneNumber")\
        .send_keys(phone_number)
    payments_form.find_element_by_id("bookFlight_contactDetails_email").send_keys(email_address)
    payments_form.find_element_by_id("bookFlight_statute").click()
开发者ID:dankon,项目名称:eskypl_tests,代码行数:30,代码来源:eskypl_tests.py

示例11: add_advanced_filter

    def add_advanced_filter(self, key: str, value: str) -> None:
        """Add a new advanced filter"""

        # Toggle the filter panel if it is not open yet
        self.toggle_selected_advanced_filters(display=True)

        # Select the last <select> available
        filter_row_xpath = '(//div[contains(@class, "selected-advanced-filters")]/div[contains(@class, "js-filter-item")])[last()]'
        filter_row = self.findBy('xpath', filter_row_xpath)
        filter_select_xpath = f'//select[contains(@class, "filter-key-select")]'
        select = Select(self.findBy('xpath', filter_select_xpath, base=filter_row))

        # If it already has a key selected, click "add filter" to add a new row
        # and select the <select> again
        if select.first_selected_option.text != '---':
            self.findBy('id', 'filter-add-new').click()
            filter_row = self.findBy('xpath', filter_row_xpath)
            select = Select(
                self.findBy('xpath', filter_select_xpath, base=filter_row))

        # Select the key, wait for the values to be loaded and select one
        select.select_by_value(key)
        self.wait_for('xpath', filter_row_xpath + '//div[contains(@class, "loading-indicator-filter-key")]', visibility=False)
        self.findBy('xpath', f'//div[contains(@class, "filter-value-column")]//input[@value="{value}"]', base=filter_row).click()
        self.apply_filter()
开发者ID:CDE-UNIBE,项目名称:qcat,代码行数:25,代码来源:base.py

示例12: select_report

        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)
开发者ID:AlinT,项目名称:Socorro-Tests,代码行数:29,代码来源:base_page.py

示例13: do_speller

	def do_speller (self):
		driver = self.driver
		answer_dict = self.answer_dict

		speller_url = self.url + self.assignment_number + '/speller'
		driver.get(speller_url)
		
		select_speed = Select(driver.find_element_by_id('speller-prompt'))
		select_speed.select_by_visible_text("Don't Speak")
		try:
			alert = driver.switch_to_alert()
			alert.accept()
		except NoAlertPresentException:
			pass
		driver.implicitly_wait(3)
		counter = 0
		while True:
			try:
				driver.implicitly_wait(3)
				question=driver.find_element_by_css_selector("*[class^='qDef lang-en TermText']").text
				inputA = driver.find_element_by_id('speller-inp')
				time.sleep(.5)
				try: # this throws an exception when its done
					inputA.click()
				except: #specify element is not visible exception
					self.speak_remainder.run('Finished Speller')
					break
				inputA.clear()
				inputA.send_keys(answer_dict[question])
				inputA.send_keys(Keys.RETURN)
				driver.get(speller_url)
				completed = driver.find_element_by_id('overall-percent').text
				 
				try:
					completed = int(completed.replace('%', ''))
					if completed % 10 == 0 and completed != 0: 
						phrase = completed + ' completed'
						self.speak_remainder.run(phrase) 
				except ValueError:
					continue
				except TypeError:
					continue

			except TimeoutException:
				print 'Timeout'
				continue

			except NoSuchElementException:
				counter += 1
				try:
					if driver.find_element_by_id('game-over').text != "":
						self.speak_remainder.run('Finished Speller')
						break
				except NoSuchElementException:
					continue
				if counter == 3:
					print 'stuck'
				else:
					print 'Reloading'	
					continue
开发者ID:h3y4w,项目名称:Quizlet-Automator,代码行数:60,代码来源:aq.py

示例14: select_drop_down

 def select_drop_down(self, drop_down_locator, value):
     element = self.find_clickable_element(drop_down_locator)
     if element:
         my_select = Select(element)
         my_select.select_by_value(value)
     else:
         raise Exception('Unable to find drop down with locator %s' % str(drop_down_locator))
开发者ID:agustincatalano,项目名称:py_frame,代码行数:7,代码来源:base_page.py

示例15: create_run

    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
开发者ID:GovardhanN,项目名称:moztrap-tests,代码行数:35,代码来源:create_run_page.py


注:本文中的selenium.webdriver.support.select.Select类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。