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


Python WebDriverWait.find_element_by_id方法代码示例

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


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

示例1: test_live_societe_login_using_third_party_modal

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_id [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.find_element_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。