def test_redirect(base_url, selenium, method, uri):
    HEADING_TEXT = 'Maintenance Mode'
    HEADING_SELECTOR = '#content-main > h1'
    MM_URL_TEMPLATE = '{locale}/maintenance-mode'

    locale = 'en-US'

    url = urljoin(base_url, uri.format(locale=locale))

    if method.lower() == 'get':
        # We do a get on the given URL but wait for the
        # maintenance-mode page to load via redirection.
        selenium.get(url)
        mm_page = BasePage(selenium, base_url, locale=locale)
        mm_page.URL_TEMPLATE = MM_URL_TEMPLATE
        mm_page.wait_for_page_to_load()
        mm_heading = mm_page.find_element(By.CSS_SELECTOR, HEADING_SELECTOR)
        assert mm_heading.is_displayed()
        assert HEADING_TEXT in mm_heading.text
        assert mm_page.is_maintenance_mode_banner_displayed
        assert not mm_page.header.is_signin_displayed
    else:
        request_method = getattr(requests, method.lower())
        resp = request_method(url, allow_redirects=True)
        # The final response should be a successful load of the
        # maintenance-mode page in the given locale.
        assert resp.status_code == 200
        assert resp.url == urljoin(base_url,
                                   MM_URL_TEMPLATE.format(locale=locale))
        pq = PyQuery(resp.text)
        assert HEADING_TEXT in pq(HEADING_SELECTOR).text()
        assert (BasePage.MM_BANNER_TEXT in
                pq(BasePage.MM_BANNER_SELECTOR).text())
        assert not pq.is_(BasePage.Header.SIGNIN_SELECTOR)
def test_revision_in_mm(base_url, selenium):
    # Get the link for the first (could be any) revision of the test document.
    page = BasePage(selenium, base_url)
    page.URL_TEMPLATE = '/{locale}/docs/User:anonymous:uitest$history'
    page.open()
    rev_link = page.find_element(By.CSS_SELECTOR,
                                 ('div.revision-list-contain ul.revision-list '
                                  'li:first-child div.revision-list-date a'))
    # Check that we're not displaying the "REVERT TO THIS REVISION" button.
    page.URL_TEMPLATE = rev_link.get_attribute('href')
    page.open()
    assert not page.is_element_displayed(By.CSS_SELECTOR,
                                         'article > a.button.revert-revision')
    assert page.is_maintenance_mode_banner_displayed
    assert not page.header.is_signin_displayed
예제 #3
0
def test_compare_revisions_in_mm(base_url, selenium):
    # Load the page that compares two revisions of a document.
    page = BasePage(selenium, base_url)
    page.URL_TEMPLATE = '/{locale}/docs/Web/CSS$history'
    page.open()
    compare_button = page.find_element(
        By.CSS_SELECTOR,
        ('div.revision-list-contain > form > '
         'div.revision-list-controls > input.link-btn')
    )
    compare_button.click()
    # Check that we're not displaying the "Change Revisions" link.
    page = BasePage(selenium, base_url)
    page.URL_TEMPLATE = '/{locale}/docs/Web/CSS$compare'
    page.wait_for_page_to_load()
    assert not page.is_element_displayed(
        By.CSS_SELECTOR, '#compare-revisions a.change-revisions')
    assert page.is_maintenance_mode_banner_displayed
    assert not page.header.is_signin_displayed
예제 #4
0
def test_revision_in_mm(base_url, selenium):
    # Get the link for the first (could be any) revision of the test document.
    page = BasePage(selenium, base_url)
    page.URL_TEMPLATE = '/{locale}/docs/User:anonymous:uitest$history'
    page.open()
    rev_link = page.find_element(
        By.CSS_SELECTOR,
        ('div.revision-list-contain ul.revision-list '
         'li:first-child div.revision-list-date a')
    )
    # Check that we're not displaying the "REVERT TO THIS REVISION" button.
    page.URL_TEMPLATE = rev_link.get_attribute('href')
    page.open()
    assert not page.is_element_displayed(
        By.CSS_SELECTOR, 'article > a.button.revert-revision')
    assert page.is_maintenance_mode_banner_displayed
    assert not page.header.is_signin_displayed
def test_redirect(base_url, selenium, method, uri):
    HEADING_TEXT = 'Maintenance Mode'
    HEADING_SELECTOR = '#content-main > h1'
    MM_URL_TEMPLATE = '{locale}/maintenance-mode'

    locale = 'en-US'

    url = urljoin(base_url, uri.format(locale=locale))

    if method.lower() == 'get':
        # We do a get on the given URL but wait for the
        # maintenance-mode page to load via redirection.
        selenium.get(url)
        mm_page = BasePage(selenium, base_url, locale=locale)
        mm_page.URL_TEMPLATE = MM_URL_TEMPLATE
        mm_page.wait_for_page_to_load()
        mm_heading = mm_page.find_element(By.CSS_SELECTOR, HEADING_SELECTOR)
        assert mm_heading.is_displayed()
        assert HEADING_TEXT in mm_heading.text
        assert mm_page.is_maintenance_mode_banner_displayed
        assert not mm_page.header.is_signin_displayed
    else:
        request_method = getattr(requests, method.lower())
        resp = request_method(url, allow_redirects=True)
        # The final response should be a successful load of the
        # maintenance-mode page in the given locale.
        assert resp.status_code == 200
        assert resp.url == urljoin(base_url,
                                   MM_URL_TEMPLATE.format(locale=locale))
        pq = PyQuery(resp.text)
        assert HEADING_TEXT in pq(HEADING_SELECTOR).text()
        assert (BasePage.MM_BANNER_TEXT
                in pq(BasePage.MM_BANNER_SELECTOR).text())
        assert not pq.is_(BasePage.Header.SIGNIN_SELECTOR)
예제 #6
0
def test_user_profile_in_mm(base_url, selenium):
    # Check that the edit button is not displayed for a user profile.
    page = BasePage(selenium, base_url)
    page.URL_TEMPLATE = '/{locale}/profiles/test-moderator'
    page.open()
    assert not page.is_element_displayed(By.ID, 'edit-user')
    assert page.is_maintenance_mode_banner_displayed
    assert not page.header.is_signin_displayed
예제 #7
0
def base_page(browser):
    page = BasePage(browser)
    page.go_to(url="http://demo.opencart.com/")
    # page.go_to(url="http://localhost//")
    return page
예제 #8
0
def base_page(browser):
    page = BasePage(browser)
    page.go_to(url="http://localhost//")
    return page
예제 #9
0
 def is_date_filter_applied(self):
     from pages.base import BasePage
     base = BasePage(self.testsetup)
     return base.date_start_from_url and base.date_end_from_url or False
예제 #10
0
def auto_log(driver, config):
    page = BasePage(driver)
    page._log_in(config['kenny'], config['kenny_pas'])
    return HomePage(page.driver)
예제 #11
0
def base_page(driver):
    return BasePage(driver)
def test_compare_revisions_in_mm(base_url, selenium):
    # Load the page that compares two revisions of a document.
    page = BasePage(selenium, base_url)
    page.URL_TEMPLATE = '/{locale}/docs/Web/CSS$history'
    page.open()
    compare_button = page.find_element(
        By.CSS_SELECTOR, ('div.revision-list-contain > form > '
                          'div.revision-list-controls > input.link-btn'))
    compare_button.click()
    # Check that we're not displaying the "Change Revisions" link.
    page = BasePage(selenium, base_url)
    page.URL_TEMPLATE = '/{locale}/docs/Web/CSS$compare'
    page.wait_for_page_to_load()
    assert not page.is_element_displayed(
        By.CSS_SELECTOR, '#compare-revisions a.change-revisions')
    assert page.is_maintenance_mode_banner_displayed
    assert not page.header.is_signin_displayed
예제 #13
0
 def __init__(self, driver):
     BasePage.__init__(self, driver)
     self.open("/login")
예제 #14
0
 def choice_bid(self):
     """选择标的"""
     #定位投标这个按钮
     e = BasePage.wait_clickable_element(self.bid_locator)
     #点击
     e.click()
예제 #15
0
 def get_user_info(self):
     """获取首页的用户信息"""
     user_ele = BasePage.wait_present_element((By.XPATH, "//a[@href='/Member/index.html']"))
     return user_ele