Skip to content

Commit 2a8420d

Browse files
committed
Added test for how_it_works.
Tests that Skip all steps button redirects the user to the last step of how it works. B Button hides once is pressed. Also tests that if user passes how it works steps normally, the button disappears at the final step.
1 parent 597dee1 commit 2a8420d

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

tests/common/how_it_works/__init__.py

Whitespace-only changes.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import pytest
2+
from selenium.webdriver.common.by import By
3+
from selenium.webdriver.support import expected_conditions
4+
from selenium.webdriver.common.keys import Keys
5+
from codebender_testing.utils import SeleniumTestCase
6+
from selenium.webdriver.support.ui import WebDriverWait
7+
8+
# How long to wait before we give up on trying to assess the result of commands
9+
TIMEOUT = 30
10+
11+
class TestHowItWorks(SeleniumTestCase):
12+
13+
@pytest.fixture(scope="class")
14+
def skip_button_display (self):
15+
skip_button = self.driver.find_element_by_id('skip-all-steps-button')
16+
assert skip_button.text == "Skip all steps"
17+
18+
def test_how_it_works(self, tester_logout):
19+
""" opens browser to codebender how_it_works """
20+
self.open("/how_it_works")
21+
assert "Blink : codebender" in self.driver.title
22+
23+
def test_skip_button (self):
24+
skip_button = self.driver.find_element_by_id('skip-all-steps-button')
25+
skip_button.send_keys(Keys.ENTER)
26+
WebDriverWait(self.driver, TIMEOUT).until(
27+
expected_conditions.text_to_be_present_in_element(
28+
(By.CSS_SELECTOR, ".popover-title"), "That's all for now."
29+
)
30+
)
31+
skip_button = self.driver.find_element_by_id('skip-all-steps-button')
32+
skip_button.is_displayed() == False
33+
self.driver.refresh()
34+
assert "Blink : codebender" in self.driver.title
35+
36+
def test_how_it_works_page_1 (self, skip_button_display):
37+
WebDriverWait(self.driver, TIMEOUT).until(
38+
expected_conditions.text_to_be_present_in_element(
39+
(By.CSS_SELECTOR, "#hiw-one .popover-title"),
40+
"Awesome editor (1/6)"
41+
)
42+
)
43+
next_button = self.find('#hiw-one .popover-content .btn-primary')
44+
next_button.click()
45+
46+
def test_how_it_works_page_2 (self, skip_button_display):
47+
WebDriverWait(self.driver, TIMEOUT).until(
48+
expected_conditions.text_to_be_present_in_element(
49+
(By.CSS_SELECTOR, "#hiw-two .popover-title"),
50+
"Helpful utilities (2/6)"
51+
)
52+
)
53+
next_button = self.find('#hiw-two .popover-content .btn-primary')
54+
next_button.click()
55+
56+
def test_how_it_works_page_3 (self, skip_button_display):
57+
WebDriverWait(self.driver, TIMEOUT).until(
58+
expected_conditions.text_to_be_present_in_element(
59+
(By.CSS_SELECTOR, "#hiw-three .popover-title"),
60+
"Compile & Upload (3/6)"
61+
)
62+
)
63+
verify_button = self.find('#cb_cf_verify_btn')
64+
verify_button.click()
65+
66+
def test_how_it_works_page_4 (self, skip_button_display):
67+
WebDriverWait(self.driver, TIMEOUT).until(
68+
expected_conditions.text_to_be_present_in_element(
69+
(By.CSS_SELECTOR, "#hiw-four .popover-title"),
70+
"Better error output (4/6)"
71+
)
72+
)
73+
insert_text = """
74+
var cursor_position = editor.aceEditor.getCursorPosition();
75+
editor.aceEditor.getSession().insert(cursor_position, ';')
76+
"""
77+
self.execute_script(insert_text, "editor")
78+
verify_button = self.find('#cb_cf_verify_btn')
79+
verify_button.click()
80+
81+
82+
def test_how_it_works_page_5 (self, skip_button_display):
83+
WebDriverWait(self.driver, TIMEOUT).until(
84+
expected_conditions.text_to_be_present_in_element(
85+
(By.CSS_SELECTOR, "#hiw-five .popover-title"),
86+
"Share (5/6)"
87+
)
88+
)
89+
next_button = self.find('#hiw-five .popover-content .btn-primary')
90+
next_button.click()
91+
92+
93+
def test_how_it_works_page_6 (self, skip_button_display):
94+
WebDriverWait(self.driver, TIMEOUT).until(
95+
expected_conditions.text_to_be_present_in_element(
96+
(By.CSS_SELECTOR, "#hiw-six .popover-title"),
97+
"Collaborate (6/6)"
98+
)
99+
)
100+
finish_button = self.find('.popover-content .btn-primary')
101+
finish_button.click()
102+
103+
def test_how_it_works_page_7 (self):
104+
skip_button = self.driver.find_element_by_id('skip-all-steps-button')
105+
skip_button.is_displayed() == False
106+
WebDriverWait(self.driver, TIMEOUT).until(
107+
expected_conditions.text_to_be_present_in_element(
108+
(By.CSS_SELECTOR,
109+
'.navbar .popover:nth-child(3) .popover-title'),
110+
"That's all for now."
111+
)
112+
)

0 commit comments

Comments
 (0)