Skip to content

Commit

Permalink
Replace mark.viewport('mobile') with selenium_mobile fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
jgmize committed Jun 29, 2019
1 parent cabdd15 commit 0520586
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
18 changes: 8 additions & 10 deletions tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

import pytest

VIEWPORT = {
'desktop': {'width': 1280, 'height': 1024},
'mobile': {'width': 320, 'height': 480}}


@pytest.fixture
def capabilities(request, capabilities):
Expand Down Expand Up @@ -59,10 +55,12 @@ def filter_capabilities(request):


@pytest.fixture
def selenium(request, selenium):
viewport = VIEWPORT['desktop']
request_keywords_viewport = request.keywords.get('viewport')
if hasattr(request_keywords_viewport, 'args'):
viewport = VIEWPORT[request_keywords_viewport.args[0]]
selenium.set_window_size(viewport['width'], viewport['height'])
def selenium(selenium):
selenium.set_window_size(1280, 1024) # width, height
return selenium


@pytest.fixture
def selenium_mobile(selenium):
selenium.set_window_size(320, 480) # width, height
return selenium
14 changes: 6 additions & 8 deletions tests/functional/test_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,20 @@ def test_communities_region_menus(slug, base_url, selenium):


@pytest.mark.nondestructive
@pytest.mark.viewport('mobile')
def test_spaces_mobile_navigation(base_url, selenium):
page = SpacesPage(selenium, base_url, slug='').open()
def test_spaces_mobile_navigation(base_url, selenium_mobile):
page = SpacesPage(selenium_mobile, base_url, slug='').open()
assert not page.is_desktop_nav_displayed
assert page.is_mobile_nav_displayed
expected_url = '/contact/spaces/mountain-view/'
page.select_mobile_nav_item('Mountain View', expected_url)
assert expected_url in selenium.current_url, 'Page did not navigate to expected URL'
assert expected_url in selenium_mobile.current_url, 'Page did not navigate to expected URL'


@pytest.mark.nondestructive
@pytest.mark.viewport('mobile')
def test_communities_mobile_navigation(base_url, selenium):
page = CommunitiesPage(selenium, base_url, slug='').open()
def test_communities_mobile_navigation(base_url, selenium_mobile):
page = CommunitiesPage(selenium_mobile, base_url, slug='').open()
assert not page.is_desktop_nav_displayed
assert page.is_mobile_nav_displayed
expected_url = '/contact/communities/north-america/'
page.select_mobile_nav_item('North America', expected_url)
assert expected_url in selenium.current_url, 'Page did not navigate to expected URL'
assert expected_url in selenium_mobile.current_url, 'Page did not navigate to expected URL'
5 changes: 2 additions & 3 deletions tests/functional/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ def test_slideshow_displayed(base_url, selenium):


@pytest.mark.nondestructive
@pytest.mark.viewport('mobile')
def test_list_displayed(base_url, selenium):
page = HistoryPage(selenium, base_url).open()
def test_list_displayed(base_url, selenium_mobile):
page = HistoryPage(selenium_mobile, base_url).open()
assert not page.is_slideshow_displayed
assert not page.is_previous_button_displayed
assert not page.is_next_button_displayed
11 changes: 5 additions & 6 deletions tests/functional/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@ def test_navigation(base_url, selenium):


@pytest.mark.nondestructive
@pytest.mark.viewport('mobile')
def test_mobile_navigation(base_url, selenium):
page = HomePage(selenium, base_url).open()
def test_mobile_navigation(base_url, selenium_mobile):
page = HomePage(selenium_mobile, base_url).open()
page.navigation.show()
firefox_desktop_page = page.navigation.open_firefox_desktop_page()
assert firefox_desktop_page.seed_url in selenium.current_url
assert firefox_desktop_page.seed_url in selenium_mobile.current_url

page.open()
page.navigation.show()
developer_edition_page = page.navigation.open_developer_edition_page()
assert developer_edition_page.seed_url in selenium.current_url
assert developer_edition_page.seed_url in selenium_mobile.current_url

page.open()
page.navigation.show()
about_page = page.navigation.open_about_page()
assert about_page.seed_url in selenium.current_url
assert about_page.seed_url in selenium_mobile.current_url

0 comments on commit 0520586

Please sign in to comment.