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


Python ui.Select方法代码示例

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


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

示例1: test_budg_filter_opts

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def test_budg_filter_opts(self, selenium):
        self.get(selenium, self.baseurl + '/transactions')
        budg_filter = Select(selenium.find_element_by_id('budget_filter'))
        # find the options
        opts = []
        for o in budg_filter.options:
            opts.append([o.get_attribute('value'), o.text])
        assert opts == [
            ['None', ''],
            ['7', 'Income (income)'],
            ['1', 'Periodic1'],
            ['2', 'Periodic2'],
            ['3', 'Periodic3 Inactive'],
            ['4', 'Standing1'],
            ['5', 'Standing2'],
            ['6', 'Standing3 Inactive']
        ] 
开发者ID:jantman,项目名称:biweeklybudget,代码行数:19,代码来源:test_transactions.py

示例2: test_filter_opts

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def test_filter_opts(self, selenium):
        self.get(selenium, self.baseurl + '/ofx')
        acct_filter = Select(selenium.find_element_by_id('account_filter'))
        # find the options
        opts = []
        for o in acct_filter.options:
            opts.append([o.get_attribute('value'), o.text])
        assert opts == [
            ['None', ''],
            ['1', 'BankOne'],
            ['2', 'BankTwoStale'],
            ['3', 'CreditOne'],
            ['4', 'CreditTwo'],
            ['6', 'DisabledBank'],
            ['5', 'InvestmentOne']
        ] 
开发者ID:jantman,项目名称:biweeklybudget,代码行数:18,代码来源:test_ofx.py

示例3: test_1_modal_from_url

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def test_1_modal_from_url(self, base_url, selenium):
        self.baseurl = base_url
        self.get(selenium, base_url + '/scheduled/2')
        modal, title, body = self.get_modal_parts(selenium)
        self.assert_modal_displayed(modal, title, body)
        assert title.text == 'Edit Scheduled Transaction 2'
        assert body.find_element_by_id(
            'sched_frm_id').get_attribute('value') == '2'
        assert body.find_element_by_id(
            'sched_frm_description').get_attribute('value') == 'ST2'
        assert body.find_element_by_id(
            'sched_frm_type_monthly').is_selected()
        assert body.find_element_by_id(
            'sched_frm_type_date').is_selected() is False
        assert body.find_element_by_id(
            'sched_frm_type_per_period').is_selected() is False
        assert body.find_element_by_id(
            'sched_frm_day_of_month').get_attribute('value') == '4'
        assert body.find_element_by_id(
            'sched_frm_amount').get_attribute('value') == '222.22'
        acct_sel = Select(body.find_element_by_id('sched_frm_account'))
        assert acct_sel.first_selected_option.get_attribute('value') == '1'
        budget_sel = Select(body.find_element_by_id('sched_frm_budget'))
        assert budget_sel.first_selected_option.get_attribute('value') == '2'
        assert selenium.find_element_by_id('sched_frm_active').is_selected() 
开发者ID:jantman,项目名称:biweeklybudget,代码行数:27,代码来源:test_scheduled.py

示例4: select_combo

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def select_combo(self, element, option):
        """
        Selects the option on the combobox.

        :param element: Combobox element
        :type element: Beautiful Soup object
        :param option: Option to be selected
        :type option: str

        Usage:

        >>> #Calling the method:
        >>> self.select_combo(element, "Chosen option")
        """
        combo = Select(self.driver.find_element_by_xpath(xpath_soup(element)))
        value = next(iter(filter(lambda x: x.text[0:len(option)] == option, combo.options)), None)

        if value:
            time.sleep(1)
            text_value = value.text
            combo.select_by_visible_text(text_value)
            print(f"Selected value for combo is: {text_value}") 
开发者ID:totvs,项目名称:tir,代码行数:24,代码来源:base.py

示例5: test_stick_to_top_admin

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def test_stick_to_top_admin(self):
        self.browser.get(self.live_server_url + reverse("niji:index"))
        login(self.browser, 'super', '123')
        self.assertIn("Log out", self.browser.page_source)

        lucky_topic1 = getattr(self, 't%s' % random.randint(1, 50))

        self.browser.get(self.live_server_url+reverse('niji:topic', kwargs={"pk": lucky_topic1.pk}))
        self.browser.find_element_by_class_name('move-topic-up').click()
        up_level = WebDriverWait(
            self.browser, 10
        ).until(
            expected_conditions.presence_of_element_located(
                (By.NAME, 'move-topic-up-level')
            )
        )
        up_level = Select(up_level)
        up_level.select_by_visible_text('1')
        time.sleep(1)
        self.browser.execute_script("$('.modal-confirm').click()")
        self.browser.get(self.live_server_url+reverse('niji:index'))
        first_topic_title = self.browser.find_elements_by_class_name('entry-link')[0].text

        self.assertEqual(first_topic_title, lucky_topic1.title) 
开发者ID:ericls,项目名称:niji,代码行数:26,代码来源:tests.py

示例6: test_changeinfo

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def test_changeinfo():
    '''
       修改个人信息
       '''
    test_login()
    driver.get('{0}/user/changeinfo'.format(site_url))
    driver.find_element_by_id('rawpass').send_keys('131322')
    driver.find_element_by_id('user_email').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_truename').send_keys('giser')
    s1 = Select(driver.find_element_by_id('def_gender'))
    s1.select_by_value("Female")
    driver.find_element_by_id('def_birthday').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_mobile').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_location').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_profile').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_postalcode').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_certificatetype').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_certificate').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_company').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_interest').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_high').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_weight').send_keys('giser@osgeo.cn')
    s1 = Select(driver.find_element_by_id('def_bloodtype'))
    s1.select_by_value("B")
    driver.find_element_by_xpath('//button[@class="btn btn-primary"]').click() 
开发者ID:bukun,项目名称:TorCMS,代码行数:27,代码来源:test_foo.py

示例7: set_select_by_text

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def set_select_by_text(self, select, text):
        '''
        Set the selected value of a select element by the visible text.

        Parameters
        ----------
        select: str or selenium.webdriver.remote.webelement.WebElement
            Any valid CSS selector or a selenium element
        text: str
            The visible text in the select element option. (Not the value)

        '''
        if isinstance(select, str):
            elem = self.get_element(select)
        else:
            elem = select

        sel = Select(elem)
        sel.select_by_visible_text(text) 
开发者ID:IntuitiveWebSolutions,项目名称:PyWebRunner,代码行数:21,代码来源:WebRunner.py

示例8: set_select_by_value

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def set_select_by_value(self, select, value):
        '''
        Set the selected value of a select element by the value.

        Parameters
        ----------
        select: str or selenium.webdriver.remote.webelement.WebElement
            Any valid CSS selector or a selenium element
        value: str
            The value on the select element option. (Not the visible text)

        '''
        if isinstance(select, str):
            elem = self.get_element(select)
        else:
            elem = select

        sel = Select(elem)
        sel.select_by_value(value) 
开发者ID:IntuitiveWebSolutions,项目名称:PyWebRunner,代码行数:21,代码来源:WebRunner.py

示例9: __init__

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def __init__(self):
        'stst\resources\linux\chromedriver'
        # cur_dir = os.path.dirname(__file__) # 'stst/features'
        # path = os.path.join(cur_dir, 'resources')
        # print(cur_dir)
        driver = webdriver.Chrome()
        driver.get("http://asiya.cs.upc.edu/demo/asiya_online.php#")
        time.sleep(3)
        driver._switch_to.frame(driver.find_element_by_id("demo-content"))
        elem = Select(driver.find_element_by_id("input"))
        elem.select_by_value("raw")
        elem = driver.find_element_by_id("no_tok")
        elem.click()
        elem = Select(driver.find_element_by_id("srclang"))
        elem.select_by_value("en")
        elem = Select(driver.find_element_by_id("trglang"))
        elem.select_by_value("en")
        elem = Select(driver.find_element_by_id("srccase"))
        elem.select_by_value("ci")
        elem = Select(driver.find_element_by_id("trgcase"))
        elem.select_by_value("ci")

        self.driver = driver 
开发者ID:rgtjf,项目名称:Semantic-Texual-Similarity-Toolkits,代码行数:25,代码来源:features_mt.py

示例10: reload

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def reload(self):
        driver = self.driver
        driver.get("http://asiya.cs.upc.edu/demo/asiya_online.php#")
        time.sleep(3)
        driver._switch_to.frame(driver.find_element_by_id("demo-content"))
        elem = Select(driver.find_element_by_id("input"))
        elem.select_by_value("raw")
        elem = driver.find_element_by_id("no_tok")
        elem.click()
        elem = Select(driver.find_element_by_id("srclang"))
        elem.select_by_value("en")
        elem = Select(driver.find_element_by_id("trglang"))
        elem.select_by_value("en")
        elem = Select(driver.find_element_by_id("srccase"))
        elem.select_by_value("ci")
        elem = Select(driver.find_element_by_id("trgcase"))
        elem.select_by_value("ci")
        self.driver = driver 
开发者ID:rgtjf,项目名称:Semantic-Texual-Similarity-Toolkits,代码行数:20,代码来源:features_mt.py

示例11: create_new_action_out_basic

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def create_new_action_out_basic(self, aname, action_type, adesc=''):
        # click on the create action button
        self.selenium.find_element_by_class_name('js-create-action').click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'id_name')))

        # Set the name, description and type of the action
        self.selenium.find_element_by_id('id_name').send_keys(aname)
        desc = self.selenium.find_element_by_id('id_description_text')
        # Select the action type
        select = Select(self.selenium.find_element_by_id('id_action_type'))
        select.select_by_value(action_type)
        desc.send_keys(adesc)
        desc.send_keys(Keys.RETURN)
        # Wait for the spinner to disappear, and then for the button to be
        # clickable
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.XPATH, '//*[@id="action-out-editor"]')
            )
        ) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:26,代码来源:__init__.py

示例12: create_new_survey_action

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def create_new_survey_action(self, aname, adesc=''):
        # click on the create action button
        self.selenium.find_element_by_class_name('js-create-action').click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'id_name')))

        # Set the name, description and type of the action
        self.selenium.find_element_by_id('id_name').send_keys(aname)
        desc = self.selenium.find_element_by_id('id_description_text')
        # Select the action type
        select = Select(self.selenium.find_element_by_id('id_action_type'))
        select.select_by_value(models.Action.SURVEY)
        desc.send_keys(adesc)
        desc.send_keys(Keys.RETURN)
        # Wait for the spinner to disappear, and then for the button to be
        # clickable
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.XPATH, '//*[@id="action-in-editor"]')
            )
        )
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        ) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:26,代码来源:__init__.py

示例13: open_condition

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def open_condition(self, cname, xpath=None):
        # Select the right button element
        if not xpath:
            xpath = \
                '//div[@id="condition-set"]' \
                '/div/h5[contains(normalize-space(), "{0}")]' \
                '/../div/button[contains(@class, "js-condition-edit")]'.format(
                    cname
                )

        # Wait for the element to be clickable, and click
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.XPATH, xpath))
        )
        self.selenium.find_element_by_xpath(xpath).click()

        # Wait for the modal to open
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'id_description_text')))
        WebDriverWait(self.selenium, 10).until(
            ElementHasFullOpacity((By.XPATH, '//div[@id="modal-item"]'))
        ) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:24,代码来源:__init__.py

示例14: test_number_kanbancolumns_for_case_not_default

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def test_number_kanbancolumns_for_case_not_default(self):
        driver = self.selenium
        issue = Issue(title="title", kanbancol=KanbanColumn.objects.get(project=self.project, name="Todo"),
                      due_date=str(datetime.date.today()), priority=3, storypoints=2, description="blubber",
                      project=self.project
                      )
        issue.save()
        issue.assignee.add(self.user)

        driver.get("{}{}".format(self.live_server_url, reverse('issue:create',
                                                               kwargs={'project': self.project2.name_short})))
        driver.find_element_by_id("id_title").send_keys("title")
        # assert that 2nd project has one kanban col more
        self.assertEqual(len(Select(driver.find_element_by_id("id_kanbancol")).options), 5)

        # assert that dependsOn now has one entry
        driver.get('{}{}'.format(self.live_server_url, reverse('backlog:backlog',
                                                               kwargs={'project': self.project.name_short}
                                                               )))
        driver.find_element_by_link_text("New issue").click()
        driver.find_element_by_xpath("(//input[@type='search'])[2]").send_keys('\n')
        time.sleep(1)
        self.assertEqual(len(driver.find_elements_by_css_selector('#select2-id_dependsOn-results li')), 1)
        for i in driver.find_elements_by_css_selector('#select2-id_dependsOn-results li'):
            self.assertIn("title", i.text) 
开发者ID:iguana-project,项目名称:iguana,代码行数:27,代码来源:test_create_and_edit.py

示例15: test_edit_same_settings_as_set

# 需要导入模块: from selenium.webdriver.support import ui [as 别名]
# 或者: from selenium.webdriver.support.ui import Select [as 别名]
def test_edit_same_settings_as_set(self):
        driver = self.selenium
        issue = Issue(title="title", kanbancol=KanbanColumn.objects.get(project=self.project, name="Todo"),
                      due_date=str(datetime.date.today()), priority=3, storypoints=2, description="blubber",
                      project=self.project
                      )
        issue.save()
        issue.assignee.add(self.user)
        driver.get("{}{}".format(self.live_server_url, reverse('issue:edit',
                                 kwargs={'project': self.project.name_short, 'sqn_i': issue.number})))
        self.assertEqual(len(Select(driver.find_element_by_id("id_kanbancol")).options), 4)

        # issue must not depend on itself
        driver.find_element_by_xpath("(//input[@type='search'])[2]").send_keys('\n')
        time.sleep(1)
        self.assertEqual(len(driver.find_elements_by_css_selector('#select2-id_dependsOn-results li')), 1)
        for i in driver.find_elements_by_css_selector('#select2-id_dependsOn-results li'):
            self.assertEqual(i.text, "No results found") 
开发者ID:iguana-project,项目名称:iguana,代码行数:20,代码来源:test_create_and_edit.py


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