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


Python WebDriverWait.is_enabled方法代码示例

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


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

示例1: test_user_interface

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_enabled [as 别名]
    def test_user_interface(self):
        self.browser_login_admin(**self.admin_data)
        self.browse_to(self.distributed_data_export_url)

        # Check that group is disabled until facility is selected
        group_select = WebDriverWait(self.browser, 30).until(EC.presence_of_element_located((By.ID, "group-name")))
        self.assertFalse(group_select.is_enabled(), "UI error")

        # Select facility, wait, and ensure group is enabled
        facility_select = self.browser.find_element_by_id("facility-name")

        self.assertEqual(len(facility_select.find_elements_by_tag_name('option')), 2, "Invalid Number of Facilities")

        for option in facility_select.find_elements_by_tag_name('option'):
            if option.text == self.facility.name:
                option.click() # select() in earlier versions of webdriver
                break

        # Check that group is enabled now
        while True:
            try:
                group_select = WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.ID, "group-name")))
                WebDriverWait(self.browser, 5).until(lambda *_: group_select.is_enabled())
                break
            except StaleElementReferenceException:
                # This exception occurs once in a while because the element is
                # somehow attached/detached/rebuilt by some clever JS
                continue

        # Click and make sure something happens
        # note: not actually clicking the download since selenium cannot handle file save dialogs
        export = self.browser.find_element_by_id("export-button")
        self.assertTrue(export.is_enabled(), "UI error")
开发者ID:arceduardvincent,项目名称:ka-lite,代码行数:35,代码来源:control_panel.py

示例2: test_user_interface_teacher

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_enabled [as 别名]
    def test_user_interface_teacher(self):
        teacher_username, teacher_password = 'teacher1', 'password'
        self.teacher = self.create_teacher(username=teacher_username,
                                           password=teacher_password)
        self.browser_login_teacher(username=teacher_username,
                                   password=teacher_password,
                                   facility_name=self.teacher.facility.name)
        self.browse_to(self.distributed_data_export_url)

        facility_select = WebDriverWait(self.browser, 30).until(EC.presence_of_element_located((By.ID, "facility-name")))
        self.assertFalse(facility_select.is_enabled(), "UI error")

        for option in facility_select.find_elements_by_tag_name('option'):
            if option.text == self.teacher.facility.name:
                self.assertTrue(option.is_selected(), "Invalid Facility Selected")
                break

        # Check that group is enabled now
        group_select = WebDriverWait(self.browser, 30).until(EC.presence_of_element_located((By.ID, "group-name")))
        WebDriverWait(self.browser, 5).until(lambda *_: group_select.is_enabled())

        # Click and make sure something happens
        # note: not actually clicking the download since selenium cannot handle file save dialogs
        export = self.browser.find_element_by_id("export-button")
        self.assertTrue(export.is_enabled(), "UI error")
开发者ID:arceduardvincent,项目名称:ka-lite,代码行数:27,代码来源:control_panel.py

示例3: fresh_find

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_enabled [as 别名]
def fresh_find(root, EC, timeout=2, retries=10):
    for i in range(retries):
        try:
            elem = WebDriverWait(root, timeout).until(EC)
            elem.is_enabled()
            return elem
        except StaleElementReferenceException:
            print('attempting to recover from StaleElementReferenceException...')
            time.sleep(0.25)
    raise StaleElementReferenceException("All {} tries yielded stale elements".format(retries))
开发者ID:A-Malone,项目名称:pokemon-showdown-ai-api,代码行数:12,代码来源:selenium_utils.py

示例4: upload

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_enabled [as 别名]
def upload(driver, path):
    print('Uploading at %s ...' % UPLOAD_URL)
    driver.get(UPLOAD_URL)
    print('...')

    elem = WebDriverWait(driver, 30).until(
        EC.visibility_of_element_located((By.CLASS_NAME, 'upload-file'))
    )
    elem = driver.find_element_by_id('upload-addon')

    print('...')
    elem.send_keys(path)
    print('Uploading %s ...' % path)
    elem = driver.find_element_by_id('upload-file-finish')
    WebDriverWait(driver, 300).until(lambda x: elem.is_enabled())

    print('Adding version ...')
    elem.click()
开发者ID:rubenrap,项目名称:foxtrick,代码行数:20,代码来源:amo_upload.py

示例5: _do_test

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import is_enabled [as 别名]
    def _do_test(self):
        driver = self.driver
        driver.get('http://localhost:5000')
        self.assertEqual('AskSO - StackOverflow Python Question Assistant', driver.title)
        next_button = WebDriverWait(driver, 20).until(
            expected_conditions.visibility_of_element_located((By.ID, IDs.next_button)))
        assert isinstance(next_button, WebElement)
        driver.implicitly_wait(0.3)

        find = driver.find_element_by_id

        def button_text(text):
            self.assertEqual(text, next_button.get_attribute('value'))

        def starts_with(elem, text):
            self.assertEqual(text, elem.text[:len(text)])

        main_message = find('main-message')

        always_displayed = set()

        def displayed(*elems):
            self.assertEqual(always_displayed.union(elems),
                             set([i for i in all_ids
                                  if driver.find_element_by_id(i).is_displayed()]))

        button_text('Start')
        starts_with(main_message, "Welcome! I'm going to help you")
        displayed(IDs.next_button)

        next_button.click()
        always_displayed |= set([IDs.code_editor, IDs.run])
        displayed()

        run = find(IDs.run)

        def set_editor_text(name, text):
            driver.execute_script("%s_editor.setValue('%s')" % (name, text))

        set_code = partial(set_editor_text, 'code')
        set_output = partial(set_editor_text, 'output')

        def run_code(code):
            set_code(code)
            run.click()

        def results(*texts):
            children = find('results').find_elements_by_xpath("./*")
            self.assertEqual(len(texts), len(children))
            for child, text in zip(children, texts):
                starts_with(child, text)

        run_code('input()')
        displayed(IDs.stdin_error)
        results()

        run_code('test_error')
        results('There was an error on the server!',
                'Traceback')
        displayed()

        run_code('print("hi.")')
        always_displayed |= set([IDs.next_button])
        displayed()
        results('Output:',
                'hi.')

        next_button.click()
        starts_with(main_message, 'Is the code as short as possible?')
        button_text('Yes')
        displayed()

        next_button.click()
        starts_with(main_message, 'Have you tried your best to solve the problem?')
        button_text('Yes')
        displayed()

        next_button.click()
        starts_with(main_message, 'What result are you trying to get?')
        button_text('Done')
        self.assertFalse(next_button.is_enabled())
        always_displayed |= set([IDs.expected_output])
        displayed()

        set_output('a')
        self.assertTrue(next_button.is_enabled())
        set_output('')
        self.assertFalse(next_button.is_enabled())

        set_output('a\\nb')
        next_button.click()
        always_displayed |= set([IDs.question])
        displayed()
        starts_with(main_message, 'Congratulations! Here is the basic text')
        button_text('Regenerate question')

        question = find(IDs.question)

        def question_text(text):
            actual_text = question.get_attribute('value')
#.........这里部分代码省略.........
开发者ID:alexmojaki,项目名称:askso,代码行数:103,代码来源:__init__.py


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