forked from mozilla/mcom-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_contribute.py
executable file
·103 lines (83 loc) · 4.4 KB
/
test_contribute.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import pytest
import requests
from unittestzero import Assert
from pages.desktop.contribute import Contribute, Signup
class TestContribute:
@pytest.mark.nondestructive
def test_footer_section(self, mozwebqa):
contribute_page = Contribute(mozwebqa)
contribute_page.go_to_page()
bad_links = []
for link in Contribute.Footer.footer_links_list:
url = contribute_page.link_destination(link.get('locator'))
if not url.endswith(link.get('url_suffix')):
bad_links.append('%s does not end with %s' % (url, link.get('url_suffix')))
Assert.equal(0, len(bad_links), '%s bad links found: ' % len(bad_links) + ', '.join(bad_links))
@pytest.mark.nondestructive
def test_tabzilla_links_are_correct(self, mozwebqa):
contribute_page = Contribute(mozwebqa)
contribute_page.go_to_page()
Assert.true(contribute_page.header.is_tabzilla_panel_visible)
contribute_page.header.toggle_tabzilla_dropdown()
bad_links = []
for link in Contribute.Header.tabzilla_links_list:
url = contribute_page.link_destination(link.get('locator'))
if url.find(link.get('url_suffix')) < 1:
bad_links.append('%s does not end with %s' % (url, link.get('url_suffix')))
Assert.equal(0, len(bad_links), '%s bad links found: ' % len(bad_links) + ', '.join(bad_links))
@pytest.mark.nondestructive
def test_major_link_destinations_are_correct(self, mozwebqa):
contribute_page = Contribute(mozwebqa)
contribute_page.go_to_page()
bad_links = []
for link in contribute_page.major_links_list:
url = contribute_page.link_destination(link.get('locator'))
if not url.endswith(link.get('url_suffix')):
bad_links.append('%s does not end with %s' % (url, link.get('url_suffix')))
Assert.equal(0, len(bad_links), '%s bad links found: ' % len(bad_links) + ', '.join(bad_links))
@pytest.mark.nondestructive
def test_major_link_urls_are_valid(self, mozwebqa):
contribute_page = Contribute(mozwebqa)
contribute_page.go_to_page()
bad_urls = []
for link in contribute_page.major_links_list:
url = contribute_page.link_destination(link.get('locator'))
response_code = contribute_page.get_response_code(url)
if response_code != requests.codes.ok:
bad_urls.append('%s is not a valid url - status code: %s.' % (url, response_code))
Assert.equal(0, len(bad_urls), '%s bad urls found: ' % len(bad_urls) + ', '.join(bad_urls))
@pytest.mark.nondestructive
def test_sign_up_form_fields_are_visible(self, mozwebqa):
contribute_page = Contribute(mozwebqa)
contribute_page.go_to_page()
signup_page = contribute_page.click_signup()
bad_fields = []
for field in signup_page.sign_up_form_fields:
if not signup_page.is_element_visible(*field.get('locator')):
bad_fields.append('The field at %s is not visible' % field.get('locator')[1:])
Assert.equal(0, len(bad_fields), '%s bad fields found: ' % len(bad_fields) + ', '.join(bad_fields))
@pytest.mark.nondestructive
def test_sign_up_form_is_visible(self, mozwebqa):
signup_page = Signup(mozwebqa)
signup_page.go_to_page()
Assert.true(signup_page.is_sign_up_form_present, 'The sign up form is not present on the page.')
def test_coding_signup_form(self, mozwebqa):
signup_page = Signup(mozwebqa)
signup_page.go_to_page()
signup_page.click_coding_topic()
signup_page.select_random_coding_subtopic()
signup_page.complete_sign_up_form()
confirmation_page = signup_page.click_submit_button()
Assert.true('coding' in confirmation_page.confirmation_text())
def test_testing_signup_form(self, mozwebqa):
signup_page = Signup(mozwebqa)
signup_page.go_to_page()
signup_page.click_testing_topic()
signup_page.select_random_testing_subtopic()
signup_page.complete_sign_up_form()
confirmation_page = signup_page.click_submit_button()
Assert.true('testing' in confirmation_page.confirmation_text())