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


Python Select.select_by_index方法代码示例

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


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

示例1: test_add_lost_pet

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
    def test_add_lost_pet(self):
        self.login()
        self.assertIn('Cadastrar Pet', self.browser.page_source)

        self.browser.get(self.live_server_url + '/pets/new/')

        name = self.browser.find_element_by_name('name')
        name.send_keys('Test')

        description = self.browser.find_element_by_name('description')
        description.send_keys('Testing')

        kind = self.browser.find_element_by_name('kind')
        kind = Select(kind)
        kind.select_by_index(1)

        self.select_dropdown('city', 1)

        profile_picture = self.browser.find_element_by_name('profile_picture')
        profile_picture.send_keys('{}/img/{}.jpg'.format(settings.STATICFILES_DIRS[0], 'sapa'))

        submit = self.browser.find_element_by_name('submit')
        submit.click()

        self.assertIn('Testing', self.browser.page_source)
        self.assertInHTML('<h2>Test - Desaparecido</h2>', self.browser.page_source)
开发者ID:pombredanne,项目名称:pets,代码行数:28,代码来源:tests.py

示例2: create_new_system

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
 def create_new_system(self,fqdn):
     driver=self.driver
     driver.get(self.hub_url)
     simple_search=driver.find_element_by_xpath("//input[@class='search-query']")
     simple_search.send_keys(fqdn)
     simple_search.send_keys(Keys.RETURN)
     if "Items found: 0" in driver.page_source :
         driver.find_element_by_xpath("//a[@class='btn btn-primary']").click()
         driver.find_element_by_xpath("//input[@id='form_fqdn']").send_keys(fqdn)
         lab=WebDriverSelect(driver.find_element_by_id("form_lab_controller_id"))
         lab.select_by_index(1)
         Type=WebDriverSelect(driver.find_element_by_id("form_type"))
         Type.select_by_value("Machine")
         Status=WebDriverSelect(driver.find_element_by_id("form_status"))
         Status.select_by_value("Automated")
         driver.find_element_by_xpath("//a[@class='btn btn-primary']").click()
     else:
         driver.get(self.hub_url+"view/"+fqdn)
         driver.find_element_by_xpath("//a[@class='btn']").click()
         Type=WebDriverSelect(driver.find_element_by_id("form_status"))
         Type.select_by_value("Automated")
         driver.find_element_by_xpath("//a[@class='btn btn-primary']").click()
     #set power type
     driver.get(self.hub_url+"view/"+fqdn+"#power")
     time.sleep(10)
     Power_type=WebDriverSelect(driver.find_element_by_id("power_power_type_id"))
     Power_type.select_by_index(1)
     driver.find_element_by_xpath("//div[@id='power']//button[@class='btn btn-primary']").click
开发者ID:xuanjia,项目名称:beaker-webauto,代码行数:30,代码来源:common.py

示例3: EditBulkCSVFile

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
class EditBulkCSVFile(BasePageCMS):

    def __init__(self, driver, wait):
        self.driver = driver
        self.wait = wait
        self.contentProject = Select(self.wait.until(lambda driver : driver.find_element_by_id("id_content_project")))
        self.sourceFile = self.wait.until(lambda driver : driver.find_element_by_id("id_file"))
        self.uploadStatus = self.wait.until(lambda driver : driver.find_element_by_xpath("//div/label[text()='Bulk upload status:']/../p"))
    
    def selectContentProjectByIndex(self, index):
        self.contentProject.select_by_index(index)
        
    def typeSourceFile(self, filePath):
        self.sourceFile.send_keys(filePath)
    
    def clickSaveAndContinueEditingButton(self):
        self.clickSaveAndContinueEditing()
        return EditBulkCSVFile(self.driver, self.wait)
    
    def clickImportItButton(self):
        self.clickOnLink("Import it")
        return EditBulkCSVFile(self.driver, self.wait)
    
    def getContentProject(self):
        return self.contentProject.first_selected_option.text
    
    def getCurrentSourceFile(self):
        currentFile = self.wait.until(lambda driver : driver.find_element_by_xpath("//div/label[text()='Source file:']/../p/a"))
        return currentFile.text
    
    def getUploadStatus(self):
        return self.uploadStatus.text
开发者ID:cbalea,项目名称:LM-AUTOMATION,代码行数:34,代码来源:bulk_csv_cms.py

示例4: add_new_user

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
    def add_new_user(self):
        add_user_btn = self.browser.find_element_by_id('new-user-btn')
        add_user_btn.click()

        self.wait_for_element_with_id('first_name', timeout=10)
        popup = self.browser.find_element_by_class_name('popup-wrap')

        first_name_field = popup.find_element_by_id('first_name')

        last_name_field = popup.find_element_by_id('last_name')

        other_name_field = popup.find_element_by_id('other_name')
        phone_field = popup.find_element_by_id('phone')
        website_field = popup.find_element_by_id('website')
        department_field = popup.find_element_by_id('department')
        email_field = popup.find_element_by_id('email')
        password_field = popup.find_element_by_id('password')
        confirm_password_field = popup.find_element_by_id('confirm_password')
        submit_user_field = popup.find_element_by_id('submit-user')
        gender_ddl = Select(popup.find_element_by_id('gender'))

        first_name_field.send_keys('blaise')
        last_name_field.send_keys('pascal')
        other_name_field.send_keys('adam')
        phone_field.send_keys('+234578362728')
        department_field.send_keys('Computing Network Team')
        website_field.send_keys('www.google.com')
        email_field.send_keys('[email protected]')
        password_field.send_keys('pass1')
        confirm_password_field.send_keys('pass1')
        gender_ddl.select_by_index(1)
        submit_user_field.click()

        return {'email': '[email protected]', 'name': 'pascal, blaise adam', 'phone': '+234578362728',
                'department': 'Computing Network Team'}
开发者ID:pophils,项目名称:TaskManagement,代码行数:37,代码来源:manage_user.py

示例5: edit_user

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
    def edit_user(self):
        edit_user_btn = self.browser.find_element_by_css_selector('.btn.btn-primary')
        edit_user_btn.click()

        popup = self.browser.find_element_by_class_name('popup-wrap')

        first_name_field = popup.find_element_by_id('first_name')

        last_name_field = popup.find_element_by_id('last_name')

        other_name_field = popup.find_element_by_id('other_name')
        phone_field = popup.find_element_by_id('phone')
        department_field = popup.find_element_by_id('department')
        submit_user_field = popup.find_element_by_id('submit-user')
        gender_ddl = Select(popup.find_element_by_id('gender'))

        first_name_field.clear()
        first_name_field.send_keys('Clement')
        last_name_field.clear()
        last_name_field.send_keys('Edith')
        other_name_field.clear()
        other_name_field.send_keys('adam')
        phone_field.clear()
        phone_field.send_keys('09000675457')
        department_field.clear()
        department_field.send_keys('Machine Learning')
        gender_ddl.select_by_index(2)
        submit_user_field.click()

        return {'name': 'edith, clement adam', 'phone': '09000675457', 'department': 'Machine Learning'}
开发者ID:pophils,项目名称:TaskManagement,代码行数:32,代码来源:manage_user.py

示例6: select_version_by_index

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
 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,代码行数:9,代码来源:base_page.py

示例7: test_check_job_details_page

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
    def test_check_job_details_page(self):
        driver=self.driver
	self.mine_job()
        job_id=self.submit_job()
        self.assertTrue(self.wait_job_end(job_id))
        self.open_job_page(job_id)
        recipeset_id=self.get_recipe_set_id_from_openning_job_page()
        recipe_id=self.get_recipe_id_from_openning_job_page()
        driver.find_element_by_xpath("//a[@class='btn results-tab']").click()
        driver.find_element_by_xpath("//a[@class='btn hide-results-tab']").click()
        driver.find_element_by_xpath("//button[@class='btn']").click()
        driver.find_element_by_xpath("//button[@class='btn']").click()
        #update whiteboard
        driver.find_element_by_xpath("//a[@class='list']").click()
        driver.find_element_by_id("whiteboard").send_keys("Automation-test")
        driver.find_element_by_xpath("//button[@type='submit']").click()
        #update Rentention Tag
        driver.refresh()
        table=WebDriverSelect(driver.find_element_by_id("job_retentiontag"))
        table.select_by_index(7)
        element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='ui-dialog-buttonset']/button[1]")))
        element.click()
        driver.refresh()
        table=WebDriverSelect(driver.find_element_by_id("job_retentiontag"))
        table.select_by_index(2)
        element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='ui-dialog-buttonset']/button[1]")))
        element.click()
        #Check kickstart is avaiable
        driver.refresh()
        driver.find_element_by_xpath("//a[contains(@href,'kickstart')]").click()
        self.assertIn("%post",driver.page_source)
开发者ID:xuanjia,项目名称:beaker-webauto,代码行数:33,代码来源:job.py

示例8: downloadChunk

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
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,代码行数:32,代码来源:__init__.py

示例9: update_select

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
 def update_select(el, value, by_text=False):
     select = Select(el)
     if value == '':
         select.select_by_index(0)
     elif by_text:
         select.select_by_visible_text(value)
     else:
         select.select_by_value(value)
开发者ID:SolusChristus,项目名称:bggcli,代码行数:10,代码来源:__init__.py

示例10: DG_db

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
 def DG_db(self,index):
     WebDriverWait(self.driver, 10)\
        .until(expected_conditions.visibility_of_element_located,((By.XPATH,".//*[@id='ctl00_ctl00_MasterPageContent_cpv_cqiDatabaseDropDownList']")))
     DGDB_DDL = Select(self.driver.find_element(*DG_Details.DG_DB))
     print(len(DGDB_DDL.options))
     DGDB_DDL.select_by_index(index)
     sleep(3)
     self.driver.implicitly_wait(10)
开发者ID:EFarag,项目名称:ACE_Project,代码行数:10,代码来源:DG_details_Screen.py

示例11: test_top_sort_results

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
    def test_top_sort_results(self):
        self._get_page("http://www.imdb.com/chart/top")

        select = Select(self.driver.find_element_by_name("sort"))

        sort_options = select.options
        for option in sort_options:
            select.select_by_index(sort_options.index(option))
            self._assert_search_result()
开发者ID:angel321,项目名称:functinal_tests,代码行数:11,代码来源:imdb_movie_result.py

示例12: dropdown_select_by_index

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
def dropdown_select_by_index(dropdown_web_elem, index):
    """

    :param dropdown_web_elem: select web element
    :param text: index of row
    :return:
    """
    case_value = Select(dropdown_web_elem)
    case_value.select_by_index(index)
开发者ID:ITsvetkoFF,项目名称:Kv-010.ifnul,代码行数:11,代码来源:web_elem_utils.py

示例13: selectDeleteAction

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
 def selectDeleteAction(self):
     try:
         action = Select(WebDriverWait(self.driver, 5).until(lambda driver:driver.find_element_by_name("action")))
     except: 
         action = Select(WebDriverWait(self.driver, 5).until(lambda driver:driver.find_element_by_name("user_action_select")))
     action.select_by_index(1)
     goButton = self.wait.until(lambda driver:driver.find_element_by_xpath("//button[text()='Go']"))
     goButton.submit()
     return DeletePageCMS(self.driver, self.wait)
开发者ID:cbalea,项目名称:LM-AUTOMATION,代码行数:11,代码来源:base_page_cms.py

示例14: DG_DetailsPopup

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
 def DG_DetailsPopup(self, name, desc, index):
     self.driver.find_element(*DG_Create.DG_Name).send_keys(name)
     sleep(3)
     self.driver.find_element(*DG_Create.DG_Description).send_keys(desc)
     DGDB_DDL = Select(self.driver.find_element(*DG_Create.DG_DB))
     print(len(DGDB_DDL.options))
     DGDB_DDL.select_by_index(index)
     sleep(3)
     self.driver.implicitly_wait(10)
开发者ID:EFarag,项目名称:ACE_Project,代码行数:11,代码来源:Deployment_Group.py

示例15: add_course_run

# 需要导入模块: from selenium.webdriver.support.select import Select [as 别名]
# 或者: from selenium.webdriver.support.select.Select import select_by_index [as 别名]
    def add_course_run(self):
        self.wait_for_element_visibility('button.js-add-course-run', 'add course run button visible')
        self.q(css='button.js-add-course-run').first.click()
        self.wait_for_element_visibility(
            'select.js-course-run-select option[value*=\'course\']', 'select course options visible')
        select = Select(self.browser.find_element_by_css_selector('select.js-course-run-select'))
        select.select_by_index(1)

        self.wait_for_element_visibility('button.js-remove-run', 'remove course run button visible')
开发者ID:dadasoz,项目名称:programs,代码行数:11,代码来源:pages.py


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