|
4 | 4 |
|
5 | 5 | __author__ = "yasinovskyy" |
6 | 6 |
|
7 | | -from runestone.unittest_base import module_fixture_maker, RunestoneTestCase |
8 | | -from selenium.webdriver.support import expected_conditions as EC |
9 | | -from selenium.webdriver.support.ui import WebDriverWait |
10 | | -from selenium.webdriver.common.by import By |
| 7 | +def test_r1(selenium_utils): |
| 8 | + """Initial view. Content is hidden""" |
| 9 | + su = selenium_utils |
| 10 | + su.get("index.html") |
| 11 | + su.wait_until_ready("question1") |
11 | 12 |
|
12 | | -setUpModule, tearDownModule = module_fixture_maker(__file__) |
| 13 | + q1 = su.driver.find_element_by_css_selector("#question1 div") |
| 14 | + cnamestr = q1.get_attribute("style") |
| 15 | + assert "display: none;" == cnamestr |
13 | 16 |
|
14 | 17 |
|
15 | | -class RevealQuestion_Tests(RunestoneTestCase): |
16 | | - def test_r1(self): |
17 | | - """Initial view. Content is hidden""" |
18 | | - self.driver.get(self.host + "/index.html") |
19 | | - wait = WebDriverWait(self.driver, 10) |
20 | | - try: |
21 | | - wait.until(EC.presence_of_element_located((By.ID, "reveal"))) |
22 | | - except: |
23 | | - text = self.driver.page_source |
24 | | - print(text[:300]) |
| 18 | +def test_r2(selenium_utils): |
| 19 | + """Reveal button clicked""" |
| 20 | + su = selenium_utils |
| 21 | + su.get("index.html") |
| 22 | + su.wait_until_ready("question1") |
| 23 | + t1 = su.driver.find_element_by_id("reveal") |
25 | 24 |
|
26 | | - t1 = self.driver.find_element_by_id("reveal") |
| 25 | + btn_show = t1.find_element_by_id("question1_show") |
| 26 | + btn_show.click() |
27 | 27 |
|
28 | | - q1 = t1.find_element_by_id("question1") |
| 28 | + q1 = t1.find_element_by_id("question1") |
29 | 29 |
|
30 | | - cnamestr = q1.get_attribute("style") |
31 | | - self.assertEqual("display: none;", cnamestr) |
| 30 | + cnamestr = q1.get_attribute("style") |
| 31 | + assert "display: none;" != cnamestr |
32 | 32 |
|
33 | | - def test_r2(self): |
34 | | - """Reveal button clicked""" |
35 | | - self.driver.get(self.host + "/index.html") |
36 | | - t1 = self.driver.find_element_by_id("reveal") |
37 | 33 |
|
38 | | - btn_show = t1.find_element_by_id("question1_show") |
39 | | - btn_show.click() |
| 34 | +def test_r3(selenium_utils): |
| 35 | + """Content is revealed, then hidden again""" |
| 36 | + su = selenium_utils |
| 37 | + su.get("index.html") |
| 38 | + su.wait_until_ready("question1") |
| 39 | + t1 = su.driver.find_element_by_id("reveal") |
40 | 40 |
|
41 | | - q1 = t1.find_element_by_id("question1") |
| 41 | + btn_show = t1.find_element_by_id("question1_show") |
| 42 | + btn_show.click() |
| 43 | + btn_hide = t1.find_element_by_id("question1_hide") |
| 44 | + btn_hide.click() |
42 | 45 |
|
43 | | - cnamestr = q1.get_attribute("style") |
44 | | - self.assertNotEqual("display: none;", cnamestr) |
| 46 | + q1 = su.driver.find_element_by_css_selector("#question1 div") |
| 47 | + cnamestr = q1.get_attribute("style") |
| 48 | + assert "display: none;" == cnamestr |
45 | 49 |
|
46 | | - def test_r3(self): |
47 | | - """Content is revealed, then hidden again""" |
48 | | - self.driver.get(self.host + "/index.html") |
49 | | - t1 = self.driver.find_element_by_id("reveal") |
50 | 50 |
|
51 | | - btn_show = t1.find_element_by_id("question1_show") |
52 | | - btn_show.click() |
53 | | - btn_hide = t1.find_element_by_id("question1_hide") |
54 | | - btn_hide.click() |
55 | | - |
56 | | - q1 = t1.find_element_by_id("question1") |
57 | | - |
58 | | - cnamestr = q1.get_attribute("style") |
59 | | - self.assertEqual("display: none;", cnamestr) |
60 | | - |
61 | | - def test_r4(self): |
62 | | - """Check for is_instructor test """ |
63 | | - t1 = self.driver.find_element_by_id("reveal") |
64 | | - self.assertIn("{{ if is_instructor: }}", t1.get_attribute("innerHTML")) |
| 51 | +def test_r4(selenium_utils): |
| 52 | + """Check for is_instructor test """ |
| 53 | + su = selenium_utils |
| 54 | + su.get("index.html") |
| 55 | + su.wait_until_ready("question1") |
| 56 | + t1 = su.driver.find_element_by_id("reveal") |
| 57 | + assert "{{ if is_instructor: }}" in t1.get_attribute("innerHTML") |
0 commit comments