Skip to content

Commit bb6923e

Browse files
committed
Merge branch 'various_fixes' of github.com:codebendercc/seleniumTests into various_fixes
2 parents 3e9ee03 + 185008c commit bb6923e

File tree

4 files changed

+195
-0
lines changed

4 files changed

+195
-0
lines changed

tests/alerts/__init__.py

Whitespace-only changes.

tests/alerts/test_alerts.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
from selenium.webdriver.support.ui import WebDriverWait
2+
import pytest
3+
from codebender_testing.config import TEST_PROJECT_NAME
4+
from codebender_testing.utils import SeleniumTestCase
5+
from selenium.webdriver.common.by import By
6+
from selenium.webdriver.support import expected_conditions
7+
from urlparse import urlparse
8+
9+
TIMEOUT = 30
10+
11+
class TestAlerts(SeleniumTestCase):
12+
13+
@pytest.fixture(scope="class", autouse=True)
14+
def create_test_project(self, tester_login):
15+
"""Makes sure we are logged in and have a project open before
16+
performing any of these tests."""
17+
self.create_sketch(TEST_PROJECT_NAME)
18+
19+
def test_alert(self):
20+
operation_output = self.driver.find_element_by_id('operation_output')
21+
assert "To program your Arduino from your browser, install" \
22+
" the codebender plugin." in operation_output.text
23+
24+
def test_remove_sketch(self):
25+
self.delete_project(TEST_PROJECT_NAME)
26+
27+
def test_library_example(self, tester_logout):
28+
self.open('/libraries')
29+
library_example = """
30+
var example = $('.accordion li a').map(function(){
31+
{ return this.href; }}).toArray();
32+
return example[0];
33+
"""
34+
url = self.driver.execute_script(library_example)
35+
self.open(url)
36+
output = self.driver.find_element_by_id('cb_cf_operation_output')
37+
assert "To program your Arduino from your browser, install" \
38+
" the codebender plugin or app." in output.text
39+
flash_btn = self.find('#cb_cf_flash_btn')
40+
if flash_btn.is_enabled():
41+
assert False
42+
else:
43+
pass
44+
45+
def test_embeded_view(self, tester_logout):
46+
self.open('/embed/microview_test')
47+
output = self.driver.find_element_by_id('cb_cf_operation_output')
48+
assert "To program your Arduino from your browser, install" \
49+
" the codebender plugin or app." in output.text
50+
microview_test = self.find('#microview_test')
51+
if microview_test.is_enabled():
52+
assert False
53+
else:
54+
pass
55+
56+
def test_walkthrough_page_2(self, tester_logout):
57+
self.open('/static/walkthrough/page/2')
58+
output = self.driver.find_element_by_id('cb_cf_operation_output')
59+
assert "To program your Arduino from your browser, install" \
60+
" the codebender plugin." in output.text
61+
62+
def test_walkthrough_page_3(self, tester_logout):
63+
self.open('/static/walkthrough/page/3')
64+
WebDriverWait(self.driver, TIMEOUT).until(
65+
expected_conditions.text_to_be_present_in_element(
66+
(By.CSS_SELECTOR, "#mycontainer h1 small"),
67+
"Page 2 of 5"
68+
)
69+
)
70+
current_url = urlparse(self.driver.current_url)
71+
assert current_url.path == '/static/walkthrough/page/2'
72+
73+
74+
def test_walkthrough_page_4(self, tester_logout):
75+
self.open('/static/walkthrough/page/4')
76+
WebDriverWait(self.driver, TIMEOUT).until(
77+
expected_conditions.text_to_be_present_in_element(
78+
(By.CSS_SELECTOR, "#mycontainer h1 small"),
79+
"Page 2 of 5"
80+
)
81+
)
82+
current_url = urlparse(self.driver.current_url)
83+
assert current_url.path == '/static/walkthrough/page/2'

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)