From f99e4db25f1369f99db37379e85d1e497b7687b8 Mon Sep 17 00:00:00 2001 From: Benjamin Forehand Jr Date: Fri, 27 Apr 2018 15:44:03 -0400 Subject: [PATCH] Added footer link tests. (#811) --- test/integration/pages/desktop/base.py | 26 ++++++++++++++++++++++++-- test/integration/test_home.py | 14 ++++++++++++++ test/integration/tox.ini | 2 +- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 test/integration/test_home.py diff --git a/test/integration/pages/desktop/base.py b/test/integration/pages/desktop/base.py index b9b75c04..a0fce182 100644 --- a/test/integration/pages/desktop/base.py +++ b/test/integration/pages/desktop/base.py @@ -1,4 +1,4 @@ -from pypom import Page +from pypom import Page, Region from selenium.webdriver.common.by import By @@ -10,10 +10,32 @@ class Base(Page): def __init__(self, selenium, base_url, locale='en-US', **kwargs): 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): self.wait.until( lambda _: self.find_element( *self._send_logo_locator).is_displayed()) 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() diff --git a/test/integration/test_home.py b/test/integration/test_home.py new file mode 100644 index 00000000..a247e0a3 --- /dev/null +++ b/test/integration/test_home.py @@ -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 diff --git a/test/integration/tox.ini b/test/integration/tox.ini index eac1ea81..18fff6fe 100755 --- a/test/integration/tox.ini +++ b/test/integration/tox.ini @@ -9,7 +9,7 @@ passenv = DISPLAY MOZ_HEADLESS deps = -rpipenv.txt commands = 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] commands =