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


Python WebDriverWait.select_by_visible_text方法代码示例

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


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

示例1: complete_shipping_info

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import select_by_visible_text [as 别名]
def complete_shipping_info(driver):
    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("shipping:firstname"))
    elem.send_keys("Jason")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("shipping:lastname"))
    elem.send_keys("Myers")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("shipping:company"))
    elem.send_keys("Work")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("shipping:street1"))
    elem.send_keys("117 Russel St")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("shipping:city"))
    elem.send_keys("London")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("shipping:postcode"))
    elem.send_keys("W1P6HQ")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("shipping:telephone"))
    elem.send_keys("6157966526")

    elem = WebDriverWait(driver, 100).until(lambda driver: Select(driver.find_element_by_id("shipping:country_id")))
    elem.select_by_visible_text("United Kingdom")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_css_selector("#shipping-buttons-container > button.button"))
    elem.click()
开发者ID:jasonamyers,项目名称:seleniumuitalk,代码行数:29,代码来源:driverspike.py

示例2: complete_billing_info

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import select_by_visible_text [as 别名]
def complete_billing_info(driver):
    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("billing:firstname"))
    elem.send_keys("Jason")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("billing:lastname"))
    elem.send_keys("Myers")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("billing:company"))
    elem.send_keys("Home")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("billing:email"))
    elem.send_keys("[email protected]")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("billing:street1"))
    elem.send_keys("117 Russel St")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("billing:city"))
    elem.send_keys("London")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("billing:postcode"))
    elem.send_keys("W1P6HQ")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("billing:telephone"))
    elem.send_keys("615-556-3180")

    elem = WebDriverWait(driver, 100).until(lambda driver: Select(driver.find_element_by_id("billing:country_id")))
    elem.select_by_visible_text("United Kingdom")

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_xpath("//form[@id='co-billing-form']/fieldset/ul/li[3]/label"))
    elem.click()

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_id("billing:use_for_shipping_no"))
    elem.click()

    elem = WebDriverWait(driver, 100).until(lambda driver: driver.find_element_by_css_selector("#billing-buttons-container > button.button"))
    elem.click()
开发者ID:jasonamyers,项目名称:seleniumuitalk,代码行数:38,代码来源:driverspike.py

示例3: test_stick_to_top_admin

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import select_by_visible_text [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

示例4: test_live_societe_login_using_third_party_modal

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import select_by_visible_text [as 别名]
    def test_live_societe_login_using_third_party_modal(self):
        """TODO: Docstring for test_live_societe_login_third_party_modal. This test will login to
        SOCIETE using third party authentication, after that we will wait for automatic redirect to
        contact form page. We need to fill out this form.
        :returns: return modal for third party authentication, success on fill out contact form

        """
        # Fetch and click on dropdown then click on twitter login button
        dropSelect = WebDriverWait(self.browser, 20).until(
            lambda browser: (self.browser.find_element_by_css_selector('div#navbar ul li.dropdown')))
        dropSelect.click()
        twitter_choice = dropSelect.find_element_by_id('twitter_login')
        twitter_choice.click()
        # Fill out twitter oauth form
        login_form = WebDriverWait(self.browser, 5).until(
            lambda browser: (self.browser.find_element_by_id('username_or_email')))
        login_form.send_keys('')
        password_form = WebDriverWait(self.browser, 5).until(
            lambda browser: (self.browser.find_element_by_id('password')))
        password_form.send_keys('')
        # Sign in to SOCIETE, but first wait for authomatic redirection
        select_sign_in = WebDriverWait(self.browser, 5).until(
            lambda browser: (self.browser.find_element_by_id('allow')))
        select_sign_in.click()

        # Filling out the form on contact page
        # first name, last name, email, mobile
        first_name_field = WebDriverWait(self.browser, 15).until(
            lambda browser: (self.browser.find_element_by_id('id_first_name')))
        first_name_field.send_keys('John')
        last_name_field = WebDriverWait(self.browser, 15).until(
            lambda browser: (self.browser.find_element_by_id('id_last_name')))
        last_name_field.send_keys('Doe')
        email_name_field = WebDriverWait(self.browser, 15).until(
            lambda browser: (self.browser.find_element_by_id('id_email')))
        email_name_field.send_keys('[email protected]')
        mobile_field = WebDriverWait(self.browser, 15).until(
            lambda browser: (self.browser.find_element_by_id('id_mobile')))
        mobile_field.send_keys('')

        # Birthday widget
        birthday_widget_month = WebDriverWait(self.browser, 15).until(
            lambda browser: Select(self.browser.find_element_by_id('id_birthday_month')))
        birthday_widget_month.select_by_visible_text('October')
        birthday_widget_day = WebDriverWait(self.browser, 15).until(
            lambda browser: Select(self.browser.find_element_by_id('id_birthday_day')))
        birthday_widget_day.select_by_visible_text('10')
        birthday_widget_year = WebDriverWait(self.browser, 15).until(
            lambda browser: Select(self.browser.find_element_by_id('id_birthday_year')))
        birthday_widget_year.select_by_visible_text('1992')

        # Move in date widget
        move_in_date_month = WebDriverWait(self.browser, 15).until(
            lambda browser: Select(self.browser.find_element_by_id('id_move_in_date_month')))
        move_in_date_month.select_by_visible_text('April')
        move_in_date_day = WebDriverWait(self.browser, 15).until(
            lambda browser: Select(self.browser.find_element_by_id('id_move_in_date_day')))
        move_in_date_day.select_by_visible_text('17')
        move_in_date_year = WebDriverWait(self.browser, 15).until(
            lambda browser: Select(self.browser.find_element_by_id('id_move_in_date_year')))
        move_in_date_year.select_by_visible_text('2016')

        # Move out date widget
        move_out_date_month = WebDriverWait(self.browser, 15).until(
            lambda browser: Select(self.browser.find_element_by_id('id_move_out_date_month')))
        move_out_date_month.select_by_visible_text('May')
        move_out_date_day = WebDriverWait(self.browser, 15).until(
            lambda browser: Select(self.browser.find_element_by_id('id_move_out_date_day')))
        move_out_date_day.select_by_visible_text('17')
        move_out_date_year = WebDriverWait(self.browser, 15).until(
            lambda browser: Select(self.browser.find_element_by_id('id_move_out_date_year')))
        move_out_date_year.select_by_visible_text('2016')

        # Country widget
        country_widget = WebDriverWait(self.browser, 15).until(
            lambda browser: Select(self.browser.find_element_by_id('id_country')))
        country_widget.select_by_visible_text('Serbia')

        # Message field
        message_field = WebDriverWait(self.browser, 15).until(
            lambda browser: (self.browser.find_element_by_id('id_message')))
        message_field.send_keys("Hello SOCIETE, I'm John Doe")

        # Send form
        send_form = WebDriverWait(self.browser, 15).until(
            lambda browser: (self.browser.find_element_by_xpath('//button[text()="Submit"]')))
        send_form.click()

        # assert
        self.assertIn('http://societe.herokuapp.com/success', self.browser.current_url)
        self.assertIn('http://societe.herokuapp.com/contact', self.browser.current_url)
开发者ID:Copser,项目名称:ErasmusHaus,代码行数:93,代码来源:live_testing.py


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