-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_exerciseInstance.py
More file actions
49 lines (36 loc) · 1.77 KB
/
test_exerciseInstance.py
File metadata and controls
49 lines (36 loc) · 1.77 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
39
40
41
42
43
44
45
46
47
48
49
import unittest
import random
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
class TestHome(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox(executable_path=r"C:\Users\wenmi\Documents\UTAustin\Fall2020\EE461L_SoftwareLab\geckodriver.exe")
# Start from random Exercises instance page
randNum = random.randint(0, 99)
self.driver.get("http://localhost:8080/exerciseinstance/" + str(randNum))
def tearDown(self):
self.driver.close()
# Test Text Components for Exercises Instance Pages
def test_exercise_has_category(self):
category = self.driver.find_element_by_id("exerciseCategoryText").text
category.replace("Category: ", "")
self.assertNotEqual(0, len(category))
def test_exercise_has_equipment(self):
equipment = self.driver.find_element_by_id("exerciseEquipmentText").text
equipment.replace("Equipment: ", "")
self.assertNotEqual(0, len(equipment))
def test_exercise_has_description(self):
desc = self.driver.find_element_by_id("exerciseDescriptionText").text
self.assertNotEqual(0, len(desc))
# Test existence of tables
def test_instance_has_exercise_table1(self):
exercise_table = self.driver.find_elements_by_id("exerciseTable1")
self.assertNotEqual(0, len(exercise_table))
def test_instance_has_exercise_table2(self):
exercise_table = self.driver.find_elements_by_id("exerciseTable2")
self.assertNotEqual(0, len(exercise_table))
def test_instance_has_exercise_table3(self):
exercise_table = self.driver.find_elements_by_id("exerciseTable3")
self.assertNotEqual(0, len(exercise_table))
if __name__ == '__main__':
unittest.main()