Added footer link tests. (#811)

This commit is contained in:
Benjamin Forehand Jr 2018-04-27 15:44:03 -04:00 committed by GitHub
parent fd71e7f957
commit f99e4db25f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 3 deletions

View File

@ -1,4 +1,4 @@
from pypom import Page from pypom import Page, Region
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
@ -10,10 +10,32 @@ class Base(Page):
def __init__(self, selenium, base_url, locale='en-US', **kwargs): def __init__(self, selenium, base_url, locale='en-US', **kwargs):
super(Base, self).__init__( super(Base, self).__init__(
selenium, base_url, locale=locale, timeout=10, **kwargs) selenium, base_url, locale=locale, timeout=20, **kwargs)
def wait_for_page_to_load(self): def wait_for_page_to_load(self):
self.wait.until( self.wait.until(
lambda _: self.find_element( lambda _: self.find_element(
*self._send_logo_locator).is_displayed()) *self._send_logo_locator).is_displayed())
return self return self
@property
def footer(self):
return self.Footer(self)
class Footer(Region):
_root_element = (By.CLASS_NAME, 'footer')
_legal_links = (By.CLASS_NAME, 'legalSection__link')
@property
def links(self):
return [self.Links(self, el) for el in self.find_elements(
*self._legal_links)]
class Links(Region):
@property
def name(self):
return self.root.text.split()[0]
def click(self):
self.root.click()

View File

@ -0,0 +1,14 @@
import pytest
from pages.desktop.base import Base
footer_links = ['mozilla', 'mozilla', 'about', 'legal', 'legal', 'cookies',
'report-infringement']
@pytest.mark.parametrize('i, name', enumerate(footer_links))
def test_legal_links(selenium, base_url, i, name):
"""Test links in footer load correct pages."""
page = Base(selenium, base_url).open()
page.footer.links[i].click()
assert name in selenium.current_url

View File

@ -9,7 +9,7 @@ passenv = DISPLAY MOZ_HEADLESS
deps = -rpipenv.txt deps = -rpipenv.txt
commands = commands =
pipenv install --skip-lock pipenv install --skip-lock
pipenv run pytest -v --verify-base-url --driver Firefox --html=send-test.html --self-contained-html {posargs} pipenv run pytest -v --verify-base-url -n 2 --driver Firefox --html=send-test.html --self-contained-html {posargs}
[testenv:flake8] [testenv:flake8]
commands = commands =