How to use the selenium.webdriver.support.ui.Select function in selenium

To help you get started, we’ve selected a few selenium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beaker-project / beaker / IntegrationTests / src / bkr / inttest / server / selenium / test_job_delete.py View on Github external
def job_delete(self, job):
        b = self.browser
        b.get(get_server_base() + 'jobs')
        b.find_element_by_link_text("Show Search Options").click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('jobsearch-0.table'))\
                .select_by_visible_text('Id')
        Select(b.find_element_by_name('jobsearch-0.operation'))\
                .select_by_visible_text('is')
        b.find_element_by_name('jobsearch-0.value').clear()
        b.find_element_by_name('jobsearch-0.value'). \
            send_keys('%s' % job.id)
        b.find_element_by_id('searchform').submit()

        delete_and_confirm(b, "//tr[td/a[normalize-space(text())='%s']]" % job.t_id)
        # table should have no remaining rows, since we searched by id
        b.find_element_by_xpath("//table[@id='widget']/tbody[not(./tr)]")
        b.get(get_server_base() + 'jobs/%d' % job.id)
        self.assertIn('This job has been deleted.',
                b.find_element_by_class_name('alert-warning').text)
github pandorafms / pandorafms / tests / console / include / bulk_operations.py View on Github external
def edit_modules_in_bulk(driver,module_name_list,agent_name_list,new_module_group=None,new_min=None,new_max=None,ff_threshold_list=None):

	#ff_threshold_list example: ff_threshold_list = [normal value,warning value,critical value] -> Mode Change each status

	click_menu_element(driver,"Module operations")

	driver.find_element_by_id("option").click()
	Select(driver.find_element_by_id("option")).select_by_visible_text("Edit modules in bulk")

	Select(driver.find_element_by_id("module_type")).select_by_visible_text("All")

	for module_name in module_name_list:
		Select(driver.find_element_by_id("module_name")).select_by_visible_text(module_name)

	time.sleep(3)

	for agent_name in agent_name_list:
		Select(driver.find_element_by_id("agents")).select_by_visible_text(agent_name)

	time.sleep(3)

	if new_module_group != None:
		Select(driver.find_element_by_id("id_module_group")).select_by_visible_text(new_module_group)

	if new_min != None:
		driver.find_element_by_id("text-min").clear()
		driver.find_element_by_id("text-min").send_keys(new_min)

	if new_max != None:
github eucalyptus / eucaconsole / tests / selenium / guiops / guiops / utilities.py View on Github external
def select_text_by_id(self, this_id, visible_text):
        if self.check_if_element_present_by_type("ID", this_id) is not 0:
            raise UICheckException("Element by id not present: " + this_id)
        if self.verify_visible_element_by_id(this_id) is not True:
            raise UICheckException("Element by id not visible:" + this_id)
        print "Select: Element Type: ID, Element: " + this_id + ", Text: " + visible_text
        Select(self.driver.find_element_by_id(this_id)).select_by_visible_text(visible_text)
        return 0
github open-contracting / standard / test_docs.py View on Github external
def test_language_switcher(browser, server):
    if 'localhost' in server:
        pytest.skip()

    browser.get('{}en'.format(server))

    for lang, lang_name in [
            ('es', 'Español'),
            ('fr', 'Français'),
            ('en', 'English'),
            ]:
        select = Select(browser.find_element_by_xpath("//select[@name='lang']"))
        select.select_by_visible_text(lang_name)
        assert browser.current_url == '{}{}/'.format(server, lang)
        assert lang_basic_text[lang] in browser.find_element_by_tag_name('body').text
github zweed4u / Supreme / Supreme GUI / supreme_3.py View on Github external
input('Click to continue automation...')
        try:
            customer_country = Select(webdriver_instance.find_element_by_name('order[billing_country]'))
            customer_country.select_by_value(self.billing_shipping_info['country'].upper())  # or visible text (USA or CANADA)
        except:
            print('Couldn\'t find order billing country drowpdown/value')
            input('Click to continue automation...')
        try:
            customer_card_number = webdriver_instance.find_element_by_id('nnaerb')
            customer_card_number.clear()
            customer_card_number.send_keys(self.billing_shipping_info['cardNumber'])
        except:
            print('Couldn\'t find nnaerb field (card number)')
            input('Click to continue automation...')
        try:
            customer_card_month = Select(webdriver_instance.find_element_by_name('credit_card[month]'))  # month must be padded eg. 09
            customer_card_month.select_by_value(self.billing_shipping_info['cardMonth'])
        except:
            print('Couldn\'t find credit card month dropdown/value')
            input('Click to continue automation...')
        try:
            customer_card_year = Select(webdriver_instance.find_element_by_name('credit_card[year]'))
            customer_card_year.select_by_value(self.billing_shipping_info['cardYear'])
        except:
            print('Couldn\'t find credit card year dropdown/value')
            input('Click to continue automation...')
        try:
            customer_card_cvv = webdriver_instance.find_element_by_name('credit_card[rvv]')
            customer_card_cvv.clear()
            customer_card_cvv.send_keys(self.billing_shipping_info['cardCVV'])
        except:
            print('Couldn\'t find credit_card[rvv] field (card cvv)')
github MikimotoH / DLink_Harvester / tenda_us_crawler.py View on Github external
def walkSelects():
    from selenium import webdriver
    from selenium.webdriver.support.ui import Select
    global driver
    driver = webdriver.PhantomJS()
    driver.get('http://www.tendaus.com/Default.aspx?Module=WebsiteEN&Action=DownloadCenter')
    selects = driver.find_elements_by_css_selector('.select01')
    selectPre = Select(selects[0])
    selectCity = Select(selects[1])
    selectCatId = Select(selects[2])
    for iPre in range(len(selectPre.options)):
        selectPre.select_by_index(iPre)
        print('selectPre=%d "%s"' % (iPre, selectPre.first_selected_option.text))
        for iCity in range(len(selectCity.options)):
            selectCity.select_by_index(iCity)
            print('selectCity="%d %s"' % (iCity, selectCity.first_selected_option.text))
            for iCatId in range(len(selectCatId.options)):
                selectCatId.select_by_index(iCatId)
                print('selectCatId = "%s"' % selectCatId.first_selected_option.text)
                oldText = getText("#proSearch>li>a")
                driver.find_element_by_css_selector(".searchbutton3.fl").click()
                waitTextChanged("#proSearch>li>a", oldText, 1.0, 0.5)
                for model in driver.find_elements_by_css_selector("#proSearch>li>a"):
                    print('model="%s"' % (model.text))
github Telefonica / toolium / toolium / pageelements / select_page_element.py View on Github external
def selenium_select(self):
        return SeleniumSelect(self.web_element)
github Kagee / audible-downloader / download.py View on Github external
def configure_audible_library(driver, lang):
    logging.info("Opening Audible library")
    lib_url = "https://www.audible.com/lib"
    if lang != "us":
        lib_url = lib_url.replace('.com', "." + lang)

    driver.get(lib_url)
    time.sleep(2)

    logging.info("Selecting books from 'All Time'")
    select = Select(driver.find_element_by_id("adbl_time_filter"))
    select.select_by_value("all")
    time.sleep(5)

    # Make sure we are getting the ENHANCED format
    # u'ENHANCED' u'MP332' u'ACELP16' u'ACELP85'
    s = Select(driver.find_element_by_id("adbl_select_preferred_format"))
    if len(s.all_selected_options) == 1:
        if 'ENHANCED' == s.all_selected_options[0].get_attribute("value").strip():
            logging.info("Selected format was ENHANCED, continuing")
        else:
            logging.info("Format was '%s', selecting 'ENHANCED'" % (s.all_selected_options[0].get_attribute("value"),))
            for opt in s.options:
                if "ENHANCED" == opt.get_attribute("value"):
                    opt.click()
                    time.sleep(5)
    else:
github MikimotoH / DLink_Harvester / netgear_crawler.py View on Github external
def main1(catIdx, famIdx, prdIdx, executor):
    startCatIdx, startFamIdx, startPrdIdx = catIdx, famIdx, prdIdx
    driver = webdriver.PhantomJS()
    harvest_utils.driver = driver
    driver.get('http://downloadcenter.netgear.com/')
    # click DrillDown
    waitClickable('#ctl00_ctl00_ctl00_mainContent_localizedContent_bodyCenter'
                  '_BasicSearchPanel_btnAdvancedSearch').click()
    #
    # wait Page2
    try:
        catSel = Select(waitClickable(catSelCss))
        numCat = len(catSel.options)
        for catIdx in range(startCatIdx, numCat):
            catSel = Select(waitClickable(catSelCss))
            print('catIdx=', catIdx)
            startCatIdx = 0
            catTxt = catSel.options[catIdx].text
            uprint('catTxt= '+ catTxt)
            oldText = getText(famSelCss)
            catSel.select_by_index(catIdx)
            waitTextChanged(famSelCss, oldText)
            famSel = Select(waitClickable(famSelCss))
            numFam = len(famSel.options)
            for famIdx in range(startFamIdx,numFam):
                famSel = Select(waitClickable(famSelCss))
                print('famIdx=', famIdx)
                startFamIdx = 0
                famTxt = famSel.options[famIdx].text
                uprint('famTxt= '+famTxt)
                oldText = getText(prdSelCss)
github keitaoouchi / seleniumwrapper / src / seleniumwrapper / wrapper.py View on Github external
def to_select(self):
        if self._is_selectable():
            return Select(self.unwrap)
        raise TypeError("Must be 'select' element.")