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


Python select.Select方法代码示例

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


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

示例1: select_basic

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def select_basic(ele):
    # 通过索引选中第一个
    Select(ele).select_by_index(0)
    sleep(1)

    # 通过value选中第2个
    Select(ele).select_by_value("value_2")
    sleep(1)

    # 通过文本选中第3个
    Select(ele).select_by_visible_text("测试数据3")
    sleep(1)

    # 取消已选中的项
    Select(ele).deselect_all()
    sleep(1)


# 通过文本选中所有项, 然后取消选中 
开发者ID:small99,项目名称:DevAuto,代码行数:21,代码来源:4.3.5_multi_select.py

示例2: select_all_by_text

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def select_all_by_text(ele):
    # 获取所有选项, 下面两种方式均可实现
    options = Select(ele).options
    # options = Select(ele).all_selected_options

    # 通过文本选中所有项
    for o in options:
        Select(ele).select_by_visible_text(o.text)
        sleep(0.5)

    # 取消已选中的项
    Select(ele).deselect_all()
    sleep(1)


# 通过索引选中所有项, 然后取消选中 
开发者ID:small99,项目名称:DevAuto,代码行数:18,代码来源:4.3.5_multi_select.py

示例3: select_by_index

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def select_by_index(self, element, index):
        """Select an element from a <select> <option> list.

        For some reason on Android selecting an option works but raises an
        exception....
        So... ingnore the exception.
        """
        andr = self.browser == 'android'
        if andr and self.version < StrictVersion('5.0'):
            self.click(self.drv.find_element_by_tag_name('select'))
            self.drv.switch_to.window('NATIVE_APP')
            self.click(
                self.drv.find_elements_by_tag_name('TextView')[index + 2]
            )
            self.drv.switch_to.window('WEBVIEW_0')
            return
        try:
            element.select_by_index(index)
        except WebDriverException:
            if andr:
                pass
            else:
                raise 
开发者ID:SEL-Columbia,项目名称:dokomoforms,代码行数:25,代码来源:test_selenium.py

示例4: test_change_language

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def test_change_language(self):
        survey_id = 'c0816b52-204f-41d4-aaf0-ac6ae2970925'

        # login as enumerator
        self.get('/debug/login/test_enumerator@fixtures.com')
        self.sleep()

        self.get('/enumerate/{}'.format(survey_id))

        self.sleep()
        self.wait_for_element('menu', By.CLASS_NAME)
        self.click(self.drv.find_element_by_class_name('menu'))
        lang = Select(self.drv.find_element_by_class_name('language_select'))
        self.assertEqual(len(lang.options), 3)
        self.select_by_index(lang, 1)

        self.sleep()

        title = self.drv.find_element_by_css_selector(
            '.content-padded h3').text

        self.assertEqual(title, 'ENUMERATOR_ONLY_SINGLE_SURVEY') 
开发者ID:SEL-Columbia,项目名称:dokomoforms,代码行数:24,代码来源:test_selenium.py

示例5: test_filter_object

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def test_filter_object(self):
        # User visits homepage
        self.browser.get(self.live_server_url)

        # User clicks filter book button
        self.wait_for(element_id='filter-book').click()

        # Update filter modal opens
        modal = self.wait_for(element_id='modal')

        # User changes price and book type
        book_type = self.browser.find_element_by_id("id_type")
        book_type_select = Select(book_type)
        book_type_select.select_by_index(2)

        filter_btn = modal.find_element_by_class_name('submit-btn')
        filter_btn.click()

        # User is redirected to the index with a querystring with the filter
        self.wait_for(element_id='filter-book')
        redirect_url = self.browser.current_url
        self.assertRegex(redirect_url, '/?type=3$') 
开发者ID:trco,项目名称:django-bootstrap-modal-forms,代码行数:24,代码来源:tests_functional.py

示例6: _new_project

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def _new_project(self):
        self.browser.get(self.url("/projects"))
        self.click_element("#new-project")

        # Select Portfolio
        self.select_option_by_visible_text('#id_portfolio', self.user.username)
        self.click_element("#select_portfolio_submit")
        var_sleep(2)

        # Click Add Button
        self.click_element(".app[data-app='project/simple_project'] .start-app")

        var_sleep(2)
        self.assertRegex(self.browser.title, "I want to answer some questions on Q.")

        m = re.match(r"http://.*?/projects/(\d+)/", self.browser.current_url)
        self.current_project = Project.objects.get(id=m.group(1)) 
开发者ID:GovReady,项目名称:govready-q,代码行数:19,代码来源:tests.py

示例7: select

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def select(self, label_value):
        element = Select(
            UIManager.driver().find_element_by_xpath(self.locator))
        element.select_by_visible_text(label_value) 
开发者ID:dsp-jetpack,项目名称:JetPack,代码行数:6,代码来源:ui_manager.py

示例8: select_all_by_index

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def select_all_by_index(ele):
    # 获取所有选项, 下面两种方式均可实现
    options = Select(ele).options
    for i in range(0, len(options)):
        Select(ele).select_by_index(i)
        sleep(0.5)
    # 取消已选中的项
    Select(ele).deselect_all()
    sleep(1)


# 通过value选中所有项, 然后取消选中 
开发者ID:small99,项目名称:DevAuto,代码行数:14,代码来源:4.3.5_multi_select.py

示例9: select_all_by_value

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def select_all_by_value(ele):
    # 获取所有选项, 下面两种方式均可实现
    options = Select(ele).options
    # options = Select(ele).all_selected_options

    # 通过文本选中所有项
    for o in options:
        Select(ele).select_by_value(o.get_attribute("value"))
        sleep(0.5)

    # 取消已选中的项
    Select(ele).deselect_all()
    sleep(1) 
开发者ID:small99,项目名称:DevAuto,代码行数:15,代码来源:4.3.5_multi_select.py

示例10: get_org

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def get_org(self):
        assert self.is_on_subpage('details')
        select = Select(self.BY_ID('id_details-organization'))
        return select.first_selected_option.get_attribute('value') 
开发者ID:Cadasta,项目名称:cadasta-platform,代码行数:6,代码来源:ProjectAdd.py

示例11: set_org

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def set_org(self, slug):
        assert self.is_on_subpage('details')
        select_elem = self.BY_ID('id_details-organization')
        select = Select(select_elem)
        select.select_by_value(slug)
        select_elem.location_once_scrolled_into_view 
开发者ID:Cadasta,项目名称:cadasta-platform,代码行数:8,代码来源:ProjectAdd.py

示例12: test_change_lang

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def test_change_lang(self):
        self.login()
        self.go_to('user:account-change-language')

        elem = self.by_id('language')
        lang = Select(elem)
        lang.select_by_value('de')
        elem.submit()

        WebDriverWait(self.selenium, SELENIUM_WAIT_SEC).until(
            staleness_of(elem))
        account_link = self.findNavigationLink('user:account')
        self.assertEqual('Konto', account_link.text) 
开发者ID:nextcloud,项目名称:appstore,代码行数:15,代码来源:test_change_language.py

示例13: test_wrong_algorithm

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def test_wrong_algorithm(self):
        ca = self.cas['root']
        csr = certs['pwd-cert']['csr']['pem']
        cn = 'test-add-wrong-algo.example.com'

        with self.assertSignal(pre_issue_cert) as pre, self.assertSignal(post_issue_cert) as post:
            response = self.client.post(self.add_url, data={
                'csr': csr,
                'ca': ca.pk,
                'profile': 'webserver',
                'subject_0': 'US',
                'subject_5': cn,
                'subject_alternative_name_1': True,
                'algorithm': 'wrong algo',
                'expires': ca.expires.strftime('%Y-%m-%d'),
                'key_usage_0': ['digitalSignature', 'keyAgreement', ],
                'key_usage_1': True,
                'extended_key_usage_0': ['clientAuth', 'serverAuth', ],
                'extended_key_usage_1': False,
            })
        self.assertFalse(pre.called)
        self.assertFalse(post.called)
        self.assertEqual(response.status_code, 200)

        self.assertFalse(response.context['adminform'].form.is_valid())
        self.assertEqual(
            response.context['adminform'].form.errors,
            {'algorithm': ['Select a valid choice. wrong algo is not one of the available choices.']})

        with self.assertRaises(Certificate.DoesNotExist):
            Certificate.objects.get(cn=cn) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:33,代码来源:tests_admin.py

示例14: test_with_bogus_reason

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def test_with_bogus_reason(self):
        # so the form is not valid

        reason = 'bogus'
        with self.assertSignal(pre_revoke_cert) as pre, self.assertSignal(post_revoke_cert) as post:
            response = self.client.post(self.url, data={'revoked_reason': reason})
        self.assertFalse(pre.called)
        self.assertFalse(post.called)
        self.assertNotRevoked(self.cert)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed('admin/django_ca/certificate/revoke_form.html')
        self.assertEqual(
            response.context['form'].errors,
            {'revoked_reason': ['Select a valid choice. bogus is not one of the available choices.']}) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:16,代码来源:tests_admin.py

示例15: select_dropdown

# 需要导入模块: from selenium.webdriver.support import select [as 别名]
# 或者: from selenium.webdriver.support.select import Select [as 别名]
def select_dropdown(self, element_name, index):
        element = Select(self.browser.find_element_by_name(element_name))
        element.select_by_index(index) 
开发者ID:jllorencetti,项目名称:pets,代码行数:5,代码来源:tests.py


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