forked from Andrew-Costa-10114/testing-with-selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
38 lines (29 loc) · 1.15 KB
/
tests.py
File metadata and controls
38 lines (29 loc) · 1.15 KB
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
import os
import pathlib
import unittest
from selenium import webdriver
def file_uri(filename):
return pathlib.Path(os.path.abspath(filename)).as_uri()
driver = webdriver.Chrome('path/to/the/chrome/webdrover')
class WebpageTests(unittest.TestCase):
def test_title(self):
driver.get(file_uri('index.html'))
self.assertEqual(driver.title, 'Index Page')
def test_increase(self):
driver.get(file_uri('index.html'))
increase = driver.find_element_by_id('increase')
increase.click()
self.assertEqual(int(driver.find_element_by_tag_name('h1').text), 1)
def test_decrease(self):
driver.get(file_uri('index.html'))
decrease = driver.find_element_by_id('decrease')
decrease.click()
self.assertEqual(int(driver.find_element_by_tag_name('h1').text), -1)
def test_multiple_increase(self):
driver.get(file_uri('index.html'))
increase = driver.find_element_by_id('increase')
for i in range(3):
increase.click()
self.assertEqual(int(driver.find_element_by_tag_name('h1').text), 3)
if __name__ == '__main__':
unittest.main()