forked from EFForg/https-everywhere
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_popup.py
More file actions
64 lines (53 loc) · 2.53 KB
/
test_popup.py
File metadata and controls
64 lines (53 loc) · 2.53 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
import unittest
from util import ExtensionTestCase
class TestPopup(ExtensionTestCase):
def test_rule_shown(self):
url = 'http://freerangekitten.com'
with self.load_popup_for(url):
#Open Rule Management section
see_more_prompt = self.query_selector('#RuleManagement__see_more--prompt')
see_more_prompt.click()
#Check to see if stable rule is checked
checkbox_el = self.driver.find_element_by_id('stable_ruleset_1')
self.assertTrue(checkbox_el.is_selected())
def test_disable_enable(self):
selector = '#onoffswitch__label'
checkbox = 'onoffswitch'
var_name = 'background.state.isExtensionEnabled'
# disable https everywhere
with self.load_popup_for():
el = self.query_selector(selector)
# Using query_selector does not work here if element isn't "plainly" visible on page, fails on Chrome
checkbox_el = self.driver.find_element_by_id(checkbox)
self.assertTrue(checkbox_el.is_selected())
el.click() # disable
with self.load_popup_for():
el = self.query_selector(selector)
checkbox_el = self.driver.find_element_by_id(checkbox)
self.assertFalse(checkbox_el.is_selected())
el.click()
with self.load_popup_for():
el = self.query_selector(selector)
checkbox_el = self.driver.find_element_by_id(checkbox)
self.assertTrue(checkbox_el.is_selected())
def test_http_nowhere(self):
selector = '#http-nowhere-checkbox_label'
checkbox = 'http-nowhere-checkbox'
var_name = 'background.state.httpNowhereOn'
# check default state and enable
with self.load_popup_for():
el = self.query_selector(selector)
# Using query_selector does not work here if element isn't "plainly" visible on page, fails on Chrome
checkbox_el = self.driver.find_element_by_id(checkbox)
self.assertFalse(checkbox_el.is_selected())
el.click()
# check it is enabled, and disable
with self.load_popup_for():
el = self.query_selector(selector)
checkbox_el = self.driver.find_element_by_id(checkbox)
self.assertTrue(checkbox_el.is_selected())
el.click() # disable
# check disabled
with self.load_popup_for():
checkbox_el = self.driver.find_element_by_id(checkbox)
self.assertFalse(checkbox_el.is_selected()) # default state