-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings_page.py
More file actions
135 lines (117 loc) · 6.56 KB
/
settings_page.py
File metadata and controls
135 lines (117 loc) · 6.56 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import unittest, time,re
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
class check_settings_page(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.driver = webdriver.Chrome()
cls.driver.implicitly_wait(10)
cls.driver.maximize_window()
cls.driver.title
cls.driver.get("http://localhost:5279/")
global wait
wait = WebDriverWait(cls.driver, 15)
def test_1_check_settings_page(self):
# find "settings" button and click
wait.until(EC.element_to_be_clickable((By.XPATH, ".//*[@id='drawer']/a[5]"))).click()
# check url
self.assertIn("http://localhost:5279/?settings", self.driver.current_url)
# check header title
self.assertIn("Settings",
self.driver.find_element_by_xpath(".//*[@id='header']/div/h1")
.get_attribute("textContent"))
# check cards
a = 1
while a < 6:
cards_list = self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[" + str(a) + "]")
self.assertTrue((cards_list).is_displayed())
a += 1
def test_2_run_on_startup(self):
# check "Run LBRY automatically when I start my computer" is eneabled
checkbox = self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[1]/label/input")
self.assertTrue((checkbox).is_enabled())
checkbox.click()
self.assertTrue((checkbox).is_displayed())
def test_3_download_directory(self):
#find input and check value
directory_select = self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[2]/input")
self.assertIn("/home/developer/Downloads",
directory_select.get_attribute("value"))
# change value
directory_select.click()
directory_select.clear()
directory_select.send_keys("/home/developer/Desktop")
time.sleep(3)
self.assertIn("/home/developer/Desktop",
directory_select.get_attribute("value"))
directory_select.click()
directory_select.clear()
directory_select.send_keys("/home/developer/Downloads")
time.sleep(3)
self.assertIn("/home/developer/Downloads",
directory_select.get_attribute("value"))
def test_4_bandwidth_limits_change_upload(self):
max_upload_unlim = self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[3]/div[1]/label[1]/input")
max_upload_limit = self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[3]/div[1]/label[2]/input")
# check "max upload unlimited" and "max download unlimited" is selected
self.assertTrue((max_upload_unlim).is_displayed())
# change max upload
max_upload_limit.click()
max_upload_number_input = wait.until(EC.element_to_be_clickable((By.XPATH,
".//*[@id='main-content']/main/section[3]/div[1]/label[2]/span/input")))
max_upload_number_input.click()
max_upload_number_input.send_keys("1024")
time.sleep(3)
self.driver.refresh()
self.assertIn("1024", self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[3]/div[1]/label[2]/span/input")
.get_attribute("value"))
self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[3]/div[1]/label[1]/input").click()
self.driver.refresh()
self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[3]/div[1]/label[2]/input").click()
self.assertIn("0", self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[3]/div[1]/label[2]/span/input")
.get_attribute("value"))
def test_5_bandwidth_limit_change_download(self):
# check and "max download unlimited" is selected
max_download_unlim = self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[3]/div[2]/label[1]/input")
max_download_limit = self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[3]/div[2]/label[2]/input")
self.assertTrue((max_download_unlim).is_displayed())
max_download_limit.click()
max_download_number_input = wait.until(EC.element_to_be_clickable((
By.XPATH, ".//*[@id='main-content']/main/section[3]/div[2]/label[2]/span/input")))
max_download_number_input.click()
max_download_number_input.send_keys("1024")
time.sleep(2)
self.driver.refresh()
self.assertIn("1024", self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[3]/div[2]/label[2]/span/input")
.get_attribute("value"))
self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[3]/div[2]/label[1]/input").click()
self.driver.refresh()
self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[3]/div[2]/label[2]/input").click()
self.assertIn("0", self.driver.find_element_by_xpath(".//*[@id='main-content']/main/section[3]/div[2]/label[2]/span/input")
.get_attribute("value"))
def test_6_show_nsfw_content(self):
# check "show_nsfw_content" checkbox
show_nsfw_content_checkbox = wait.until(EC.element_to_be_clickable((By.XPATH,
".//*[@id='main-content']/main/section[4]/div/label/input")))
self.assertTrue((show_nsfw_content_checkbox).is_enabled())
show_nsfw_content_checkbox.click()
self.assertTrue((show_nsfw_content_checkbox).is_displayed())
def test_7_share_diagnostic_data(self):
# check "Help make LBRY better by contributing diagnostic data about my usage" checkbox
help_checkbox = wait.until(EC.element_to_be_clickable((By.XPATH,
".//*[@id='main-content']/main/section[4]/div/label/input")))
self.assertTrue((help_checkbox).is_enabled())
help_checkbox.click()
self.assertTrue((help_checkbox).is_displayed())
@classmethod
def tearDownClass(cls):
cls.driver.close()
if __name__ == '__main__':
unittest.main()