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


Python WebDriverWait.until方法代码示例

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


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

示例1: verifico_janela_ranking_eventos

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
def verifico_janela_ranking_eventos(context):
    wait = WebDriverWait(context.driver, 5)
    elemento1 = context.driver.find_element_by_xpath("//span[contains(@class, 'nv-filterbar-title-text')and contains(text(), 'Ranking de Eventos')]")
    assert elemento1.text == u'RANKING DE EVENTOS'
    wait.until(EC.presence_of_element_located((By.XPATH, "//span[contains(@class, 'x-panel-header-text x-panel-header-text-default') and contains(text(), 'Grupos de recursos')]")))
    time.sleep(2)
    context.driver.save_screenshot('/tmp/capacity_ranking_eventos.png')
开发者ID:rfranca86,项目名称:automatizando,代码行数:9,代码来源:ispm_capacity.py

示例2: is_clickable

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
def is_clickable(driver, full_xpath, xpath, timeout = 1):
    try:
        w = WebDriverWait(driver, timeout)
        w.until(EC.element_to_be_clickable(('xpath',xpath)))
        return XPathUtil.is_clickable(full_xpath)
    except TimeoutException, ElementNotVisibleException:
        return False
开发者ID:AntBean,项目名称:OpenWPM,代码行数:9,代码来源:webdriver_extensions.py

示例3: is_visible

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
def is_visible(driver, locator_type, locator, timeout=3):
    try:
        w = WebDriverWait(driver, timeout)
        w.until(EC.visibility_of_element_located((locator_type, locator)))
        return True
    except TimeoutException:
        return False
开发者ID:AntBean,项目名称:OpenWPM,代码行数:9,代码来源:webdriver_extensions.py

示例4: __get__

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
 def __get__(self, obj, type):
     wdw = WebDriverWait(obj._driver, TIMEOUT)
     wdw.until(
         lambda driver: driver.find_elements(*self._locator),
         'Element {} not found'.format(self._locator))
     self._elements = obj._driver.find_elements(*self._locator)
     return self._elements
开发者ID:tuticfruti,项目名称:tuticfruti_blog,代码行数:9,代码来源:web_element.py

示例5: testDragAndDrop

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
    def testDragAndDrop(self):
        """Copied from org.openqa.selenium.interactions.TestBasicMouseInterface."""
        element_available_timeout = 15
        wait = WebDriverWait(self, element_available_timeout)
        self._loadPage("droppableItems")
        wait.until(lambda dr: dr._isElementAvailable("draggable"))

        if not self._isElementAvailable("draggable"):
            raise "Could not find draggable element after 15 seconds."

        toDrag = self.driver.find_element_by_id("draggable")
        dropInto = self.driver.find_element_by_id("droppable")

        holdDrag = ActionChains(self.driver) \
            .click_and_hold(toDrag)
        move = ActionChains(self.driver) \
            .move_to_element(dropInto)
        drop = ActionChains(self.driver).release(dropInto)

        holdDrag.perform()
        move.perform()
        drop.perform()

        dropInto = self.driver.find_element_by_id("droppable")
        text = dropInto.find_element_by_tag_name("p").text
        self.assertEqual("Dropped!", text)
开发者ID:Zekom,项目名称:selenium,代码行数:28,代码来源:interactions_tests.py

示例6: Task

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
class Task(object):

    def __init__(self, options):
        self.driver = webdriver.Chrome(driver_path)
        self.domain = options['domain']
        self.wait = WebDriverWait(self.driver, 10)

    @staticmethod
    def dom_ready(driver):
        state = driver.execute_script('return document.readyState')
        return state == 'complete'

    def event_signup(self, event_id):
        driver = self.driver
        driver.get('%s/event?id=%s' % (self.domain, event_id))
        self.wait.until(self.dom_ready)
        apply_elem = driver.find_element_by_class_name('join')
        apply_elem.click()
        # TODO 填值 报名

    def login(self, username, password):
        driver = self.driver
        login_url = self.domain + '/login'
        driver.get(login_url)
        form = driver.find_element_by_class_name('loginform')
        e_username = form.find_element_by_name('username')
        e_password = form.find_element_by_name('password')
        e_username.send_keys(username)
        e_password.send_keys(password)
        form.submit()
        time.sleep(2)
开发者ID:Vivomo,项目名称:python,代码行数:33,代码来源:task.py

示例7: handle_popup

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
 def handle_popup(self,cancel):
     wait = WebDriverWait(self.selenium, self.timeout)
     wait.until(EC.alert_is_present())    # throws timeout exception if not found
     popup = self.selenium.switch_to_alert()
     answer = 'cancel' if cancel else 'ok'
     print popup.text + " ...clicking " + answer
     popup.dismiss() if cancel else popup.accept()
开发者ID:jprovaznik,项目名称:cfme_pages,代码行数:9,代码来源:page.py

示例8: login_with_qr

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
 def login_with_qr(self):
     self.storage.clear()
     self.driver.refresh()
     currentsrc = None
     currentfig = None
     wait = WebDriverWait(self.driver,30)
     while True:
         if self.storage.get('WAToken1') == None:
             reloadbutton = wait.until(EC.presence_of_element_located((By.XPATH,'//*[@id="app"]/div/div/div/div[1]/div[1]/div')))
             if(reloadbutton.get_attribute('class') == "idle"):
                 reloadbutton.click()
             imagelement = wait.until(EC.presence_of_element_located((By.XPATH,'//*[@id="app"]/div/div/div/div[1]/div[1]/div/img')))
             tmp = imagelement.get_attribute('src')
             if currentsrc == tmp:
                 time.sleep(1)
                 continue
             else:
                 currentsrc = tmp
                 if currentfig!=None:
                     plt.clf()
                 currentfig = self.show_current_qr(currentsrc,currentfig)
                 continue
         else:
             if currentfig!=None:
                 plt.close(currentfig)
             break
开发者ID:draguve,项目名称:WhatsSpam,代码行数:28,代码来源:Spammer.py

示例9: _grab_current_hours

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
def _grab_current_hours():
    """
    This method will open a chrome window, log the user in to okta with
    their workiva email, open ADP Workforce, go to their timecard,
    and return their current hours.
    """
    driver = webdriver.Chrome()

    driver.get(se.ADP["okta"])

    wait = WebDriverWait(driver, 10)
    wait.until(EC.element_to_be_clickable((By.ID, "signin-button")))
    username = driver.find_element_by_id("user-signin")
    username.send_keys(se.ADP["username"])
    password = driver.find_element_by_id("pass-signin")
    password.send_keys(se.ADP["password"])
    sign_in = driver.find_element_by_id("signin-button")
    sign_in.click()

    driver.get("%shome/adp_workforce_now/" % se.ADP["okta"] + \
               "0oac91hvcoOAQQBOYUYZ/3311")

    element = wait.until(EC.element_to_be_clickable((By.ID, "Myself_navItem")))
    nav_item = driver.find_element_by_id("Myself_navItem")

    # Hover to show menu buttons.
    action = ActionChains(driver)
    action.move_to_element(nav_item)
    action.perform()

    driver.find_element_by_id("Myself_ttd_Time&Attendance_MyTimeEntry").click()

    driver.implicitly_wait(7)
开发者ID:balbir97,项目名称:opsdiary,代码行数:35,代码来源:time_hourly.py

示例10: Page

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
class Page(object):
    __metaclass__ = abc.ABCMeta

    def __init__(self, driver, base_url):
        self.driver = driver
        self.base_url = base_url
        self.wait = WebDriverWait(driver, 15)

    # locators
    SPINNER_OFF = (By.XPATH, "//div[@id='spinnerDiv' and @style='display: none;']")

    # abstracting functions
    @abc.abstractmethod
    def is_this_page(self):
        return

    # general functions
    def is_element_visible(self, locator):
        try:
            return self.wait.until(visibility_of_element_located(locator))
        except WebDriverException:
            return False

    def try_get_visible_element(self, locator):
        return self.wait.until(visibility_of_element_located(locator))

    @ErrorHandlerPO("page generation is failed")
    def wait_until_page_generate(self):
        return self.wait.until(presence_of_element_located(self.SPINNER_OFF))
开发者ID:ITsvetkoFF,项目名称:Kv-010.ifnul,代码行数:31,代码来源:page.py

示例11: wait_for_correct_document

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
        def wait_for_correct_document(_):

            current_url = self.current_url  # cache to avoid extra wire calls

            # if frame switches are failing, uncomment the following line to
            # help debug:
            #print "self.current_url = ", current_url

            if current_url != expected_url:
                # getting here may have been caused by the previous wait having
                # been called too soon before the server switched to the right
                # document.  Do it again, just in case.
                #
                # if, on the other hand, the cause was that the previous wait
                # was called an appropriate time, this shouldn't hurt us.
                #
                # (one or might FirefoxDriver change might make this
                # unnecessary.  yuck.  ideally, Marionette won't have this
                # problem, and when we switch to it, we'll be able to ditch
                # this nested wait.  we'll see).
                wait2 = WebDriverWait(self, DEFAULT_WAIT_TIMEOUT)
                wait2.until(EC.frame_to_be_available_and_switch_to_it(locator))
                return False

            return True
开发者ID:MaxMillion,项目名称:talkilla,代码行数:27,代码来源:driver.py

示例12: _get_login_raw_cookies

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
    def _get_login_raw_cookies(cls, username, password):
        """
        @brief: Login base on GUI, with consideration of vetification.
        @return: A browser driver was successfully logined.
        """

        driver = webdriver.Firefox()
        wait = WebDriverWait(driver, 10)
        driver.get(cls.LOGIN_URL)
        # try to login without vetification.
        cls._fill_username_and_password(driver, username, password)
        cls._submit(driver)

        while True:
            try:
                # wait for page load.
                wait.until(expected_conditions.title_is("新浪通行证"))
                break
            except:
                # still in login page.
                cls._fill_username_and_password(driver, username, password)
                cls._fill_vertification(driver)
                cls._submit(driver)
        # After login sina.com, we need to get login session from weibo.com.
        driver.get("http://weibo.com/")
        # wait.until(expected_conditions.title_contains("我的首页"))
        driver.close()

        return driver.get_cookies()
开发者ID:huntzhan,项目名称:WeiboTopic,代码行数:31,代码来源:utils.py

示例13: get_video

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
def get_video(video_list):
    dlq = []
    video_log_file = open('finished_video_list.txt', 'r+')
    for video in video_list:
        found = False
        for line in video_log_file:
            line = line.rstrip('\n')
            print('LINE = ' + line)
            if line in video.get_web_page_url():
                found = True
                break
        if not found:
            print('Getting a video')
            print(video.get_web_page_url())
            driver = webdriver.Chrome()
            driver.implicitly_wait(10)
            driver.get(video.get_web_page_url())
            num_attempts = 0
            while num_attempts < 4:
                try:
                    wait = WebDriverWait(driver, 10)
                    wait.until(EC.element_to_be_clickable((By.ID, 'my_video_1_html5_api')))
                    url = driver.find_element('id','my_video_1_html5_api').get_attribute('src')
                    video.set_video_page_url(url)
                    driver.close()
                    video.get_video_file()
                    break
                except TimeoutException:
                    print('Lost Connection, Attempting to re-establish...')
                    num_attempts += 1
                    if num_attempts == 4:
                        print('Skipping episode ' + video.get_id() + ' due to timeout exception.')
                        driver.close()
                        break
    video_log_file.close()
开发者ID:topfight,项目名称:AnimeDownloader,代码行数:37,代码来源:Downloader.py

示例14: test_delete_layer

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
    def test_delete_layer(self):
        """ Delete the layer """

        self.get(self.url)

        # Wait for the tables to load to avoid a race condition where the
        # toaster tables have made an async request. If the layer is deleted
        # before the request finishes it will cause an exception and fail this
        # test.
        wait = WebDriverWait(self.driver, 30)

        wait.until(EC.text_to_be_present_in_element(
            (By.CLASS_NAME,
             "table-count-recipestable"), "0"))

        wait.until(EC.text_to_be_present_in_element(
            (By.CLASS_NAME,
             "table-count-machinestable"), "0"))

        self.click('a[data-target="#delete-layer-modal"]')
        self.wait_until_visible("#delete-layer-modal")
        self.click("#layer-delete-confirmed")

        notification = self.wait_until_visible("#change-notification-msg")
        expected_text = "You have deleted 1 layer from your project: %s" % \
            self.imported_layer_version.layer.name

        self.assertTrue(expected_text in notification.text,
                        "Expected notification text \"%s\" not found instead"
                        "it was \"%s\"" %
                        (expected_text, notification.text))
开发者ID:neofang7,项目名称:ostro-os,代码行数:33,代码来源:test_layerdetails_page.py

示例15: Action

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until [as 别名]
class Action():
    def __init__(self):
        self.desired_caps = {
            "platformName": "Android",
            "deviceName": "SM_G9500",
            "appPackage": "com.tencent.mm",
            "appActivity": ".ui.LauncherUI",
            "noReset": True
        }
        self.driver = webdriver.Remote(DRIVER_SERVER, self.desired_caps)
        self.wait = WebDriverWait(self.driver, TIMEOUT)

    def entry(self):
        # 点击进入搜索
        search = self.wait.until(EC.presence_of_element_located((By.XPATH, '//android.widget.TextView[@content-desc="Search"]')))
        search.click()
        # 点击输入搜索内容
        keyword = self.wait.until(EC.presence_of_element_located((By.ID, 'com.tencent.mm:id/hx')))
        keyword.set_text(KEYWORD)
        sleep(2)
        # 点击搜索
        TouchAction(self.driver).tap(x=1299, y=2605).perform()
        sleep(2)
        # 点击公众号
        TouchAction(self.driver).tap(x=672, y=634).perform()
        # 点击右上角人像
        view_profile = self.wait.until(EC.presence_of_element_located((By.XPATH, '//android.widget.ImageButton[@content-desc="Chat Info"]')))
        view_profile.click()
        # 点击查看历史
        view_history = self.wait.until(EC.presence_of_element_located((By.XPATH, '//android.widget.LinearLayout[8]//*[@resource-id="android:id/title"]')))
        view_history.click()
        sleep(3)
        # TouchAction(self.driver).press(x=806, y=2500).move_to(x=806, y=2400).release().perform()
        self.driver.swipe(FLICK_START_X, FLICK_START_Y + 960, FLICK_START_X, FLICK_START_Y)
        sleep(1)

        while True:
            t = -450
            for i in range(6):
                try:
                    t += 440
                    sleep(1)
                    # 循环点击每篇文章图片 图片高度500px
                    # x, y根据自己手机屏幕来调整
                    TouchAction(self.driver).tap(x=1019, y=440+t).perform()
                    # 尝试再点击一次, 如果第一次点击到两个图片的中间, 并不会进入文章
                    # 图片与图片间隔180px
                    try:
                        TouchAction(self.driver).tap(x=1150, y=440+t+182).perform()
                    except:
                        pass
                    # 点击退出文章
                    sleep(2)
                    back = self.wait.until(EC.presence_of_element_located((By.ID, 'com.tencent.mm:id/i2')))
                    back.click()
                except:
                    pass
            sleep(1)
            # 模拟拖动
            self.driver.swipe(FLICK_START_X, FLICK_START_Y + 1500, FLICK_START_X, FLICK_START_Y)
开发者ID:pol9111,项目名称:tencent_WechatOffAcc_auto,代码行数:62,代码来源:spider.py


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