• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python wait.WebDriverWait类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_check_all_admin_pages

    def test_check_all_admin_pages(self):

        wait = WebDriverWait(self.driver, 5)

        self.driver.get(SIGN_IN_PAGE)
        self.driver.find_element_by_name("username").send_keys(LOGIN)
        self.driver.find_element_by_name("password").send_keys(PASSWORD)
        self.driver.find_element_by_name("login").click()

        first_menu_elements = wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "#app->a")))
        first_menu_links = [x.get_attribute("href") for x in first_menu_elements]

        for link in first_menu_links:
            self.driver.get(link)
            first_menu_item_header = self.driver.find_elements_by_css_selector("#content>h1")
            self.assertTrue(first_menu_item_header)

            second_menu_elements = self.driver.find_elements_by_css_selector(".docs a")
            second_menu_links = [x.get_attribute("href") for x in second_menu_elements]

            if second_menu_elements:
                for link in second_menu_links:
                    self.driver.get(link)
                    second_menu_item_header = self.driver.find_elements_by_css_selector("#content>h1")
                    self.assertTrue(second_menu_item_header)
开发者ID:enelf,项目名称:joker,代码行数:25,代码来源:test_exercise_7_check_menu.py


示例2: __init__

    def __init__(self):
        name = ""
        pw = ""
        while((name == "") | (pw == "")):
            name = input("Loginname: ")
            print("Login :", name)
            pw = input("Password: ")#TODO: nicer password taking
            print("PW :", pw)

        dcap = dict(DesiredCapabilities.PHANTOMJS)
        dcap["phantomjs.page.settings.userAgent"] = (
           "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53 (KHTML, like Gecko) Chrome/15.0.87")

        self.driver = webdriver.PhantomJS(desired_capabilities=dcap, service_args=['--ignore-ssl-errors=true'])

        #goto isis page because direct access is not permitted
        self.driver.get("https://isis.tu-berlin.de/")

        #wait until page is up
        wait = WebDriverWait(self.driver, 10)
        wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div.content")))

        #click shibbolethbutton to go to login page
        self.driver.find_element_by_id('shibbolethbutton').click()


        # Fill the login form and submit it
        self.driver.find_element_by_name('j_username').send_keys(name)
        self.driver.find_element_by_id('password').send_keys(pw)
        self.driver.find_element_by_name('Submit').submit()
开发者ID:DopeforHope,项目名称:isisDataFetcher,代码行数:30,代码来源:mainTest.py


示例3: get_max_page_num

 def get_max_page_num(self):
     max_num = WebDriverWait(self.driver, 20, 0.1).until(
         lambda d: d.find_element_by_class_name(self.TOTAL_NUM))
     size = max_num.get_attribute("innerText")
     if not size:
         size = max_num.text
     return int(size)
开发者ID:AlexandraSmirnova,项目名称:homework-4,代码行数:7,代码来源:pages.py


示例4: test_onclick_popup_modal_and_presents_articles_titles

    def test_onclick_popup_modal_and_presents_articles_titles(self):
        # self.create_database_record()

        # Visitor goes to home page and clicks on airplane word.
        self.browser.get(self.live_server_url)
        self.get_word('airplane').click()

        # Visitor waits until modal windows pop up.
        block = WebDriverWait(self.browser, 10)
        modal = block.until(expected_conditions.visibility_of_element_located((By.ID, 'word-details-modal')))

        # Visitor gets articles titles.
        self.check_for_title_in_article_table('airplane is faster than ship.')
        self.check_for_title_in_article_table('airplane crashed yesterday.')
        self.check_title_does_not_exist_in_article_table('rocket took off today morning.')

        # Visitor closes modal window, refreshes browser and clicks on rocket word.
        self.browser.find_element(By.XPATH, '//button[@class="btn btn-default"]').click()
        self.browser.refresh()
        self.browser.find_element_by_link_text('rocket').click()

        # Visitor waits until modal windows pop up.
        block = WebDriverWait(self.browser, 10)
        modal = block.until(expected_conditions.visibility_of_element_located((By.ID, 'word-details-modal')))

        # Visitor gets articles titles.
        self.check_title_does_not_exist_in_article_table('airplane is faster than ship.')
        self.check_title_does_not_exist_in_article_table('airplane crashed yesterday.')
        self.check_for_title_in_article_table('rocket took off today morning.')
开发者ID:wiaterb,项目名称:streszczenieinformacji,代码行数:29,代码来源:test_words_details_popup.py


示例5: wait_until_element_not_visible

    def wait_until_element_not_visible(webdriver, locator_lambda_expression,
                                       timeout=WTF_TIMEOUT_MANAGER.NORMAL, sleep=0.5):
        """
        Wait for a WebElement to disappear.

        Args:
            webdriver (Webdriver) - Selenium Webdriver
            locator (lambda) - Locator lambda expression.

        Kwargs:
            timeout (number) - timeout period
            sleep (number) - sleep period between intervals.

        """
        # Wait for loading progress indicator to go away.
        try:
            stoptime = datetime.now() + timedelta(seconds=timeout)
            while datetime.now() < stoptime:
                element = WebDriverWait(webdriver, WTF_TIMEOUT_MANAGER.BRIEF).until(
                    locator_lambda_expression)
                if element.is_displayed():
                    time.sleep(sleep)
                else:
                    break
        except TimeoutException:
            pass
开发者ID:AmyOrchid188,项目名称:wtframework,代码行数:26,代码来源:webelement.py


示例6: _attempt_download

 def _attempt_download(self, query, offset):
     real_offset = self._calculate_real_offset(offset)
     real_offset = int(real_offset)
     dictionary = {AbsWebsiteCommonApi._QUERY_MASK: query, AbsWebsiteCommonApi._OFFSET_MASK: str(real_offset)}
     url = self._multiple_replace(dictionary, self.base_url)
     page_source = None
     for i in range(0, AbsWebsiteCommonApi._DOWNLOAD_TRY_NUMBER):
         time.sleep(AbsWebsiteCommonApi._CRAWL_DELAY)
         web_page = None
         try:
             web_page = webdriver.PhantomJS()
             web_page.get(url)
             wait = WebDriverWait(web_page, AbsWebsiteCommonApi._PAGE_LOAD_TIMEOUT)
             wait.until(self.test_page_loaded)
         except Exception as exception:
             print(str(exception))
             if web_page is not None:
                 web_page.close()
             page_source = None
             continue
         page_source = web_page.execute_script(AbsWebsiteCommonApi._JAVASCRIPT_GET_PAGE_SOURCE_CODE)
         web_page.close()
         self.inc_download()
         break
     if page_source is None:
         print("ERROR - Internet connection failure")
         os.kill(os.getpid(), signal.SIGUSR1)
     return page_source
开发者ID:fpbfabio,项目名称:estimation_methods,代码行数:28,代码来源:abs_website_common_api.py


示例7: add_service

    def add_service(self):
        count = self.items_in_cart()
        Find(by=By.CSS_SELECTOR, value='.add-to-cart', context=self).click()

        if not self.item_is_sold_out():
            wait = WebDriverWait(self._driver, 10)
            wait.until(lambda x: count < self.items_in_cart())
开发者ID:ShinKaiRyuu,项目名称:Testing-MBA-SB,代码行数:7,代码来源:services_page.py


示例8: test_sort_routes

 def test_sort_routes(self):
     wait = WebDriverWait(self.driver, 15)
     self.click_first_nearby_stop('Taipei Station')
     wait.until(
         lambda driver: self.driver.find_element_by_id('nexti.android.bustaipei:id/menu_passby_sort')
     ).click()
     sleep(0.5)
     estimates = self.driver.find_elements_by_id('nexti.android.bustaipei:id/text_estimate')
     current_estimate = 0
     is_depart = False
     serv_over = False
     for estimate in estimates:
         if is_depart:
             self.assertEqual(estimate.text, 'Depart')
         elif serv_over:
             self.assertEqual(estimate.text, 'Serv Over')
         if estimate.text == 'Depart':
             is_depart = True
             continue
         elif estimate.text == 'Serv Over':
             serv_over = True
             continue
         elif estimate.text == 'Approach':
             continue
         match = re.search('(\d{0,2}) min', estimate.text)
         next_estimate = int(match.group(1))
         self.assertLessEqual(current_estimate, next_estimate)
         current_estimate = next_estimate
开发者ID:gcaaa31928,项目名称:BusTrackerTaipeiAppiumTesting,代码行数:28,代码来源:test_nearby_page_stations.py


示例9: setUp

 def setUp(self):
     super().setUp()
     wait = WebDriverWait(self.driver, 15)
     button = wait.until(
         lambda driver: self.driver.find_element_by_android_uiautomator('new UiSelector().text("Nearby")')
     )
     button.click()
开发者ID:gcaaa31928,项目名称:BusTrackerTaipeiAppiumTesting,代码行数:7,代码来源:test_nearby_page.py


示例10: is_checked

 def is_checked(self, compared_to_average):
     checkbox = WebDriverWait(self.driver, 30, 0.5).until(
         lambda d: d.find_elements_by_css_selector(self.COMPARED_TO_AVERAGE)[compared_to_average]
     )
     if checkbox.is_selected():
         return True
     return False
开发者ID:Janyell,项目名称:tech-testing-ha2,代码行数:7,代码来源:component.py


示例11: is_business_node_checked

 def is_business_node_checked(self, business_node_number):
     checkbox = WebDriverWait(self.driver, 30, 0.5).until(
         lambda d: d.find_elements_by_css_selector(self.BUSINESS_NODES_CHECKBOXES)[business_node_number + 1]
     )
     if checkbox.is_selected():
         return True
     return False
开发者ID:Janyell,项目名称:tech-testing-ha2,代码行数:7,代码来源:component.py


示例12: test_compare_products_removal_alert

    def test_compare_products_removal_alert(self):
        # get the search textbox
        search_field = self.driver.find_element_by_name("q")
        search_field.clear()

        # enter search keyword and submit
        search_field.send_keys("phones")
        search_field.submit()

        # click the Add to compare link
        self.driver.\
            find_element_by_link_text("Add to Compare").click()
            
        # click on Remove this item link, this will display # an alert to the user
        self.driver.find_element_by_link_text("Clear All").click()

        # switch to the alert
        #alert = self.driver.switch_to_alert()
        alert = WebDriverWait(self.driver,10).until(expected_conditions.alert_is_present())

        # get the text from alert
        alert_text = alert.text

        # check alert text
        self.assertEqual("Are you sure you would like to remove all products from your comparison?", alert_text)

        # click on Ok button
        alert.accept()
开发者ID:KamilZiemski,项目名称:pyDev,代码行数:28,代码来源:CompareProducts.py


示例13: publish

 def publish(link):
     driver.get(link)
     find_click(".org-module-link[href*=members]")
     type(".auto-search-input", username)
     l = lambda _driver: _driver.find_element_by_css_selector("a[href*=publicize]")
     elm = WebDriverWait(driver, 25).until(l)
     elm.click()
开发者ID:papaloizouc,项目名称:coderwall-badges-fixed,代码行数:7,代码来源:cw.py


示例14: get

    def get(self, url):
        super(WebDriverMixin, self).get('about:blank')
        full_url = urljoin(self._base_url, url)
        self.execute_script(
            """
            window.name = "{}" + window.name;
            window.location.replace("{}");
            """.format(DEFER_LABEL, full_url)
        )
        wait = WebDriverWait(self, 10)
        wait.until_not(self._location_equals, 'about:blank')

        if not self.ignore_synchronization:
            test_result = self._test_for_angular()
            angular_on_page = test_result[0]
            if not angular_on_page:
                message = test_result[1]
                raise AngularNotFoundException(
                    'Angular could not be found on page: {}:'
                    ' {}'.format(full_url, message)
                )
            # TODO: inject scripts here
            # return self.execute_script(
            #     'angular.resumeBootstrap(arguments[0]);'
            # )
            self.execute_script('angular.resumeBootstrap();')
开发者ID:tonysimpson,项目名称:pytractor,代码行数:26,代码来源:mixins.py


示例15: finds

def finds( identifier, context=None, timeout=-1, condition=None):
    """
        @return: Returns the web element found by identifier
        @rtype: selenium.webdriver.remote.webelement.WebElement
    """
    if timeout == -1:
        timeout = default_timeout

    if isinstance(identifier, WebElement):
        return identifier

    if context is None:
        context = driver

    locator = get_identifier(identifier)

    if condition is None:
        condition = count_non_zero_and_visible(locator)
    else:
        condition = condition(locator)

    wdw = WebDriverWait(driver, timeout)

    try:
        elems = wdw.until(condition)
        return elems if isinstance(elems, list) else []

    except TimeoutException:
        return []
开发者ID:dataspider99,项目名称:upworkbot,代码行数:29,代码来源:selenium_automation.py


示例16: click_first_nearby_stop

 def click_first_nearby_stop(self, place_name):
     self.click_first_search_place(place_name)
     wait = WebDriverWait(self.driver, 15)
     first_nearby_stop = wait.until(
         lambda driver: self.driver.find_element_by_xpath("//android.widget.TextView[@index='0' and @resource-id='nexti.android.bustaipei:id/text_stopname']")
     )
     first_nearby_stop.click()
开发者ID:gcaaa31928,项目名称:BusTrackerTaipeiAppiumTesting,代码行数:7,代码来源:test_nearby_page.py


示例17: banner_save

    def banner_save(self):
        self.wait_banner_image()

        element = WebDriverWait(self.driver, 30, 3).until(
            lambda el: el.find_element_by_css_selector(self.BANNER_SAVE)
        )
        element.click()
开发者ID:deyl94,项目名称:tech-testing-ha2,代码行数:7,代码来源:create_page.py


示例18: is_element_present

 def is_element_present(self, locator, timeout=3):
     try:
         wait = WebDriverWait(self.driver, timeout)
         wait.until(expected_conditions.presence_of_element_located(locator))
     except WebDriverException:
         return False
     return True
开发者ID:AnnaQC,项目名称:capture_tmp,代码行数:7,代码来源:base_page.py


示例19: _get_keyspace_shards

 def _get_keyspace_shards(self):
   wait = WebDriverWait(self.driver, 10)
   wait.until(expected_conditions.visibility_of_element_located(
       (By.TAG_NAME, 'vt-keyspace-view')))
   keyspace_content = self.driver.find_element_by_tag_name('vt-keyspace-view')
   return [sh.text for sh in
           keyspace_content.find_elements_by_class_name('vt-serving-shard')]
开发者ID:mapbased,项目名称:vitess,代码行数:7,代码来源:vtctld_web_test.py


示例20: test_select_suggest

    def test_select_suggest(self):
        self.driver.execute_script("mobile: OnScreenKeyboard.Disable")

        pivots = self.driver.find_elements_by_class_name("Windows.UI.Xaml.Controls.Primitives.PivotHeaderItem")
        pivots[1].click()

        waiter = WebDriverWait(self.driver, timeout=5)

        autosuggestion_box = waiter.until(EC.presence_of_element_located((By.ID, 'MySuggestBox')))
        autosuggestion_input = autosuggestion_box.find_element_by_class_name('Windows.UI.Xaml.Controls.TextBox')
        autosuggestion_input.send_keys('A')

        suggestions_list = waiter.until(EC.presence_of_element_located((By.XNAME, 'SuggestionsList')))
        suggestions = suggestions_list.find_elements_by_class_name('Windows.UI.Xaml.Controls.TextBlock')

        expected_text = 'A2'

        for suggest in suggestions:
            if suggest.text == expected_text:
                # When AutoSuggest is focused it moves whole view up
                # but it is not reflected coordinates that we get from driver,
                # instead of suggest.click() we will have to use Select pattern
                point = self.driver.execute_script('automation: GetClickablePoint', suggest)
                x, y = [float(v) for v in point.split(',')]
                ActionChains(self.driver).move_by_offset(x, y).click().perform()
                break

        assert expected_text == autosuggestion_input.text
开发者ID:meilke,项目名称:Winium.StoreApps,代码行数:28,代码来源:test_commands.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python selinux.getfilecon函数代码示例发布时间:2022-05-27
下一篇:
Python ui.WebDriverWait类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap