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


Python WebDriverWait.until_not方法代码示例

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


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

示例1: delete_file

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
    def delete_file(self,filename):
        """delete a file uploaded to the wiki page"""

        # get the row representing the file
        row = self.filelist.get_row_by_property('filename',filename)

        if row is None:
            raise NoSuchFileAttachmentError(
                "file named \"%s\" not uploaded" % (filename))

        # click the delete link
        row.delete.click()

        # wait for the row to disappear
        message = "row with filename %s did not disappear" % (filename)

        def condition(browser):
            self.logger.debug('waiting until row with file %s disappears' \
                % (filename))
            row = self.filelist.get_row_by_property('filename',filename)
            return row is None

        ignored_exceptions = [ TimeoutException,
                               NoSuchElementException,
                               StaleElementReferenceException ]

        w = WebDriverWait(self._browser,10,
                ignored_exceptions=ignored_exceptions)
        w.until_not(condition,message=message)
开发者ID:codedsk,项目名称:hubcheck,代码行数:31,代码来源:upload3.py

示例2: wait_for_page_element_displayed

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
    def wait_for_page_element_displayed(self,loc='css=body',displayed=True,timeout=10):

        self.logger.debug(
            "waiting for page element '%s' displayed == %s" \
            % (loc,displayed))

        def condition(browser):
            #return self.is_displayed(loc) == displayed
            return self.is_displayed(loc)

        try:
            wait = WebDriverWait(self._browser,timeout)
            if displayed:
                message='while waiting for element "%s" to load' % loc
                wait.until(condition,message=message)
            else:
                message='while waiting for element "%s" to disappear' % loc
                wait.until_not(condition,message=message)
        except TimeoutException as e:
            # save a screen shot and reraise the exception
            # browser.save_screenshot_as_base64
            # self._browser.save_screenshot_as_file("need_help.submitted-1.png")
            self.logger.exception(e)
            raise
        except StaleElementReferenceException:
            # ignore stale element reference exceptions for now.
            pass
开发者ID:codedsk,项目名称:hubcheck,代码行数:29,代码来源:basepageobject.py

示例3: test_login_required

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
    def test_login_required(self):
        """Users must be logged in to answer a question."""

        self.browser.get(SERVER_URL)
        old_title = self.browser.title
        self.browser.get(SERVER_URL+"/question")
        wait = WebDriverWait(self.browser, 10)
        wait.until_not(condition.title_is(old_title))
        assert_that(self.browser.current_url, contains_string('login'))
开发者ID:bjaress,项目名称:shortanswer,代码行数:11,代码来源:test_question_page.py

示例4: wait_until_page_not_contain_element

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
 def wait_until_page_not_contain_element(self, xpath, timeout=5):
     """
     Waits until element specified with locator disappears on current page.\n
     Fails if _"timeout"_ expires before the element disappears. Timeout should be specified in seconds.\n
     *Example usage:*
     | *Keyword* | *Argument* | *Argument* |
     | Wait Until Page Not Contain Element | //table[@id='staff']/tbody/tr[1] | 10 |
     """
     wait = WebDriverWait(self.driver, timeout=int(timeout))
     message = "Element '%s' was not deleted from page in %s second(s)." % (xpath, str(timeout))
     wait.until_not(lambda driver: driver.find_element_by_xpath(xpath), message=message)
开发者ID:rmerkushin,项目名称:Selenium2LibraryExt,代码行数:13,代码来源:elements.py

示例5: wait_until_element_is_not_visible

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
 def wait_until_element_is_not_visible(self, xpath, timeout=5):
     """
     Waits until element specified with locator is hidden.\n
     Fails if _"timeout"_ expires before the element is hidden. Timeout should be specified in seconds.\n
     *Example usage:*
     | *Keyword* | *Argument* | *Argument* |
     | Wait Until Element Is Not Visible | //div[@id='delete_confirm'] | 10 |
     """
     wait = WebDriverWait(self.driver, timeout=int(timeout))
     message = "Element '%s' was not hidden in %s second(s)." % (xpath, str(timeout))
     wait.until_not(lambda driver: driver.find_element_by_xpath(xpath).is_displayed(), message=message)
开发者ID:rmerkushin,项目名称:Selenium2LibraryExt,代码行数:13,代码来源:elements.py

示例6: clear_cache

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
def clear_cache(driver, timeout=60):
    """Clear the cookies and cache for the ChromeDriver instance."""
    # navigate to the settings page
    driver.get('chrome://settings/clearBrowserData')

    # wait for the button to appear
    wait = WebDriverWait(driver, timeout)
    wait.until(get_clear_browsing_button)

    # click the button to clear the cache
    get_clear_browsing_button(driver).click()

    # wait for the button to be gone before returning
    wait.until_not(get_clear_browsing_button)
开发者ID:gliesefire,项目名称:MyProjects,代码行数:16,代码来源:sampleCollector.py

示例7: clear_cache

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
def clear_cache(driver, timeout=60):
    """Clear the cookies and cache for the ChromeDriver instance."""
    # navigate to the settings page
    driver.get('chrome://settings/clearBrowserData')

    # wait for the button to appear
    wait = WebDriverWait(driver, timeout)
    wait.until(get_Element)

    select = Select(driver.find_element_by_css_selector('* /deep/ select#dropdownMenu'))
    select.select_by_visible_text('All time')
    # click the button to clear the cache
    get_Element(driver).click()

    # wait for the button to be gone before returning
    wait.until_not(get_Element)
开发者ID:gliesefire,项目名称:MyProjects,代码行数:18,代码来源:runner.py

示例8: wait_until_not_present

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
    def wait_until_not_present(self,message='',locator=None):

        if locator is None:
            locator = self.locators['base']

        if message == '':
            message = 'while waiting for %s to become not present' % (locator)

        def condition(browser):
            self.logger.debug('waiting until %s not present' % (locator))
            return self.owner.find_element_in_owner(locator)

        ignored_exceptions = [ TimeoutException,
                               NoSuchElementException,
                               StaleElementReferenceException ]

        w = WebDriverWait(self._browser,10,
                ignored_exceptions=ignored_exceptions)
        w.until_not(condition,message=message)
开发者ID:codedsk,项目名称:hubcheck,代码行数:21,代码来源:basepagewidget.py

示例9: fill_up_hack_nyu

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
def fill_up_hack_nyu(student):
    """ automate your hack nyu form using selenium"""
    driver = webdriver.Firefox()
    wait = WebDriverWait(driver, 10)
    # load the page
    driver.get("http://hacknyu.org/signup")
    # get the form element
    form = driver.find_element_by_css_selector("form[name='signupForm']")
    # fill the fields
    form.find_element_by_css_selector("input[name='firstName']").send_keys(student['first_name'])
    form.find_element_by_css_selector("input[name='lastName']").send_keys(student['last_name'])
    form.find_element_by_css_selector("input[name='email']").send_keys(student['email_id'])
    form.find_element_by_css_selector("input[name='password']").send_keys("technyu")
    # click and accept terms
    form.find_element_by_xpath("//input[@name='terms']/..").click()
    wait.until(EC.presence_of_element_located((By.XPATH, "//button[.='Accept']"))).click()
    wait.until_not(EC.presence_of_element_located((By.CSS_SELECTOR, ".modal")))
    # click on submit
    form.find_element_by_css_selector("button[type='submit']").click()
    driver.quit()
开发者ID:SeanRosario,项目名称:webscraping-selenium,代码行数:22,代码来源:fill_up_nyu.py

示例10: test_side_navbar

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
    def test_side_navbar(self, working_instance):  # pylint: disable=R0201
        if isinstance(working_instance, PhantomJS):
            pytest.xfail("is_displayed doesn't works correct in PhantomJS")
        list_elements = working_instance.find_elements_by_css_selector(
            '.sidebar li')
        assert len(list_elements) == 14
        assert [l.is_displayed() for l in list_elements] == \
               [True] * 8 + [False] * 4 + [True, False]
        working_instance.set_window_size(600, 1000)
        list_elements = working_instance.find_elements_by_css_selector(
            '.sidebar li')
        assert [l.is_displayed() for l in list_elements] == [False] * 14
        button = working_instance.find_element_by_css_selector(
            '.navbar-header button')
        button.click()
        wait = WebDriverWait(working_instance, 5)
        for element in list_elements[:8]:
            wait.until(EC.visibility_of(element))
        list_elements = working_instance.find_elements_by_css_selector(
            '.sidebar li')
        assert [l.is_displayed() for l in list_elements] == \
               [True] * 8 + [False] * 4 + [True, False]
        list_elements[7].click()
        for element in list_elements[8:12]:
            wait.until(EC.visibility_of(element))
        list_elements = working_instance.find_elements_by_css_selector(
            '.sidebar li')
        assert [l.is_displayed() for l in list_elements] == [True] * 12 + \
                                                            [True, False]
        list_elements[12].click()
        for element in list_elements[8:12]:
            wait.until_not(EC.visibility_of(element))

        wait.until(EC.visibility_of(list_elements[13]))
        list_elements = working_instance.find_elements_by_css_selector(
            '.sidebar li')
        assert [l.is_displayed() for l in list_elements] == [True] * 8 +\
                                                            [False] * 4 + \
                                                            [True] * 2
开发者ID:RedBeardCode,项目名称:DjConChart,代码行数:41,代码来源:test_base_layout.py

示例11: wait_until_invisible

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
    def wait_until_invisible(self,message='',locator=None):

        if locator is None:
            locator = self.locators['base']

        if message == '':
            message = 'while waiting for %s to become invisible' % (locator)

        def condition(browser):
            self.logger.debug('waiting until %s invisible' % (locator))
            e = self.owner.find_element_in_owner(locator)
            if e.is_displayed():
                return e
            else:
                return False

        ignored_exceptions = [ TimeoutException,
                               NoSuchElementException,
                               StaleElementReferenceException ]

        w = WebDriverWait(self._browser,10,
                ignored_exceptions=ignored_exceptions)
        w.until_not(condition,message=message)
开发者ID:codedsk,项目名称:hubcheck,代码行数:25,代码来源:basepagewidget.py

示例12: wait_for_element_not_present_by_id_experimental

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
    def wait_for_element_not_present_by_id_experimental(self, element_id):

        print "Executing wait_for_element_not_present_by_id(" + element_id + ")"
        print "Looking for element id = " + element_id + " in the DOM."
        print "Timeout is set to " + str(self.timeout_to_locate_element_in_seconds) + " seconds"

        wait = WebDriverWait(self.driver, self.timeout_to_locate_element_in_seconds)

        if wait.until_not(EC.presence_of_element_located((By.ID, element_id))):

            print "Verified element id = " + element_id + " not present."

        else:
            raise UICheckException
        return 0
开发者ID:suwaji,项目名称:eucaconsole,代码行数:17,代码来源:selenium_api_experimental.py

示例13: test_sel

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
 def test_sel(self):
    
    driver = webdriver.Firefox()
    driver.get("http://www.3point5.com/")
    driver.maximize_window()
    assert "3point5 | Retail Product Training - Learn and Earn! - 3point5" in driver.title
    user_name = driver.find_element_by_name("email")
    submit = driver.find_element_by_id("btn-primary")
    #send the info to the driver
    user = user_name.send_keys("[email protected]")
    submit.click()
   
    #to detect if an email address is already in use
    text_found = re.search(r'We have detected that ',driver.page_source)
    ##give an assertion error is the email id is not already in use    
    assert text_found is not None
    wait = WebDriverWait(driver,5)
#==============================================================================
#     WebDriverWait(driver, 5).until(
#         self.ajax_complete, "Timeout waiting for page to load"
#     )
#==============================================================================
    assert "No results found" not in driver.page_source
    
    #try login success
    try:
       page_loaded = wait.until_not(
       lambda driver:driver.current_url == "http://www.3point5.com/"
     )
    except TimeoutException:
       self.fail("loading Timeout expired")
    
    # Assert that the URL is now the correct post-login page
#    self.assertEqual(
#       driver.current_url,
#       "http://www.3point5.com/",
#       msg = "Successful Login"
#    )    
    

    self.assertTrue(
       driver.current_url,
       "http://www.3point5.com/",
       #msg = "Successful Login"
    )    
    #print a email id fail message
    print "We have detected that the email is already registered on 3point5.com."
    driver.close()
开发者ID:Ruby20,项目名称:Interviews,代码行数:50,代码来源:seltest.py

示例14: ServerHelper

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
class ServerHelper():
    def __init__(self, tc):
        self.tc = tc
        self.wait = WebDriverWait(tc.driver, timeout=25)
        self.controls = ServerTestControls(tc.driver)

    def _is_btn_enabled(self, btn):
        return btn.get_attribute('class').find('disabled') == -1

    def add(self, input):
        self.tc.log.info("trying add server %s" % (input.param("add_server_ip", "10.1.3.72:8091")))
        self.wait.until(lambda fn: self.controls.add_server_btn.is_displayed(),
                        "Add Server btn is not displayed in %d sec" % (self.wait._timeout))
        self.controls.add_server_btn.click()
        self.wait.until(lambda fn: self.controls.add_server_dialog().add_server_pop_up.is_displayed(),
                        "no reaction for click create new bucket btn in %d sec" % (self.wait._timeout))
        self.fill_server_info(input)
        self.controls.add_server_dialog().add_server_dialog_btn.click()
        self.controls.add_server_dialog().add_server_confirm_btn.click()
        self.wait.until_not(lambda fn:
                            self.controls.add_server_dialog().confirm_server_addition.is_displayed(),
                            "Add server pop up is not closed in %d sec" % self.wait._timeout)
        self.wait.until_not(lambda fn:
                            self.controls.add_server_dialog().add_server_pop_up.is_displayed(),
                            "Add server pop up is not closed in %d sec" % self.wait._timeout)
        self.tc.log.info("added server %s" % (input.param("add_server_ip", "10.1.3.72:8091")))

    def fill_server_info(self, input):
        self.controls.add_server_dialog().ip_address.type(input.param("add_server_ip", "10.1.3.72:8091"))
        self.controls.add_server_dialog().username.type(input.membase_settings.rest_username)
        self.controls.add_server_dialog().password.type(input.membase_settings.rest_password)

    def rebalance(self):
        self.wait.until(lambda fn: self.controls.num_pend_rebalance.is_displayed(),
                        "Number of pending rebalance servers is not displayed in %d sec" % (self.wait._timeout))
        self.wait.until(lambda fn: self._is_btn_enabled(self.controls.rebalance_btn),
                        "Rebalance btn is not enabled in %d sec" % (self.wait._timeout))
        self.controls.rebalance_btn.click()
        self.tc.log.info("Start rebalancing")
        self.wait.until_not(lambda fn: self._is_btn_enabled(self.controls.rebalance_btn),
                            "Rebalance btn is enabled in %d sec" % (self.wait._timeout))
        time.sleep(5)
开发者ID:Boggypop,项目名称:testrunner,代码行数:44,代码来源:uisampletests.py

示例15: main

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import until_not [as 别名]
def main():
    if not CRON:
        display = Display(visible=VISIBILITY, size=(1024, 768))
        display.start()

    now = datetime.now()
    browser = webdriver.Chrome()

    today = (now + relativedelta(days=+DAYS_AHEAD)).strftime("%d/%m/%Y")
    start_day_to_book = today + " {0}:00:00".format(START_TIME)
    end_day_to_book = today + " {0}:00:00".format(END_TIME)

    # check that the court isn't already been booked
    if is_court_booked(today):
        log.info("a court has been booked already for day {0}".format(today))
        sys.exit()
    log.info("booking outdoor tennis on day {0}".format(start_day_to_book))

    options = webdriver.ChromeOptions()
    options.binary_location = '/opt/google/chrome/google-chrome'
    # driver = webdriver.Firefox()
    driver = webdriver.Chrome('/usr/bin/chromedriver',
                              chrome_options=options,
                              service_args=['--verbose'],
                              service_log_path='/home/isamicaste/python/goldenlane/chrome_driver.log')
    driver.implicitly_wait(2)

    # wait
    wait = WebDriverWait(driver, 2)

    driver.get(BASE_URL)

    # insert member id
    element = driver.find_element_by_name(MEMBER_ID)
    element.send_keys(LOGIN)

    # insert password
    element = driver.find_element_by_name(PASSWORD)
    element.send_keys(PWD)

    # submit
    element = driver.find_element_by_name(SUBMIT_LOGIN)
    element.click()

    # select Tennis Outdoor 60mins from Activity
    select = Select(driver.find_element_by_name(ACTIVITY_SELECTION))
    select.select_by_value(TENNIS_ACTIVITY)


    # # insert start date TODO this doesn't work, a javascript is run when inserting text
    # element = driver.find_element_by_name("ctl00$MainContent$_advanceSearchUserControl$startDate")
    # element.send_keys(start_day_to_book)
    # insert end date
    # element = driver.find_element_by_name("ctl00$MainContent$_advanceSearchUserControl$endDate")
    # element.send_keys(end_day_to_book)

    # select start time
    select = Select(driver.find_element_by_name(START_HOUR_SELECTION))
    select.select_by_value(START_TIME)

    # select end time
    select = Select(driver.find_element_by_name(END_HOUR_SELECTION))
    select.select_by_value(END_TIME)

    # click search button
    search_button_active = False
    count = 1
    while not search_button_active and count < 400:
        try:
            element = wait.until(expected_conditions.element_to_be_clickable((By.ID, SEARCH_BUTTON)))
            # element = driver.find_element_by_id(SEARCH_BUTTON)
            element.click()
            search_button_active = True
        except StaleElementReferenceException:
            log.info('search button not yet available')
        if not search_button_active:
            count += 1
            log.info('waiting for the search button to become active')

    if not search_button_active:
        log.error('search button not available')
        sys.exit()

    # wait until the search has been performed (the search button is no more clickable)
    _element = wait.until_not(expected_conditions.element_to_be_clickable((By.ID, SEARCH_BUTTON)))

    # follow result link
    element = driver.find_element_by_id(RESULT_LINK)
    element.click()


    # cycle the next day button DAYS_AHEAD times
    for _ in xrange(DAYS_AHEAD):
        element = driver.find_element_by_name(NEXT_DAY)
        element.click()

    # check if the court has
    # book court TODO select court 1 or 2
    booked = False
    count = 1
#.........这里部分代码省略.........
开发者ID:antonigno,项目名称:goldenlane,代码行数:103,代码来源:goldenlane.py


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