Skip to content

Commit 185008c

Browse files
committed
Added test for alerts msgs when plugin is not installed.
Tests that when user is on editor, library example, embeded project view or walkthrough page without having the plugin installed message "To program your Arduino from your browser, install ... " appears.
1 parent 2a8420d commit 185008c

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-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'

0 commit comments

Comments
 (0)