-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_blog.py
68 lines (51 loc) · 1.93 KB
/
test_blog.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
"""
- test About page
- check navigation links
- check search
- test Search page
- check search box input
- check search results
- check pagination on search results
"""
import unittest
from unittest import TestCase
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from controllers import (
HomePageController,
SearchPageController
)
class BaseTest(TestCase):
@classmethod
def setUpClass(cls):
cls.browser = webdriver.Chrome()
@classmethod
def tearDownClass(cls):
cls.browser.close()
class HomePageTest(BaseTest):
def setUp(self):
homepage_controller = HomePageController(HomePageTest.browser)
homepage_controller.visit_to_home_page()
self.homepage_controller = homepage_controller
def test_title_is_present_on_home_page(self):
blog_author = self.homepage_controller.read_title()
self.assertIn('BEN ALMAN', blog_author)
def test_navigation_links(self):
links, selector = self.homepage_controller.read_nav_links()
self.assertEqual(len(links), 6)
# for num, link in enumerate(links):
# links, selector = self.homepage_controller.read_nav_links()
# self.homepage_controller.visit_nav_link(selector + ":nth-child({})".format(num+1))
class SearchPageTest(BaseTest):
def setUp(self):
searchpage_controller = SearchPageController(SearchPageTest.browser)
searchpage_controller.visit_home_page()
self.searchpage_controller = searchpage_controller
def test_make_query(self):
self.searchpage_controller.make_query('Javascript')
heading = self.searchpage_controller.view_text_in_query_result('#content_body0-inner')
self.assertTrue(heading.startswith('SEARCH RESULTS'))
results = self.searchpage_controller.view_query_results()
self.assertIn('result', results)
if __name__ == "__main__":
unittest.main()