Skip to content

Commit 84ebbc9

Browse files
committed
Added test for walkthrough pages.
Using user agent for Linux, Windows and Mac to test walkthrough pages, on each OS.
1 parent ba91708 commit 84ebbc9

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

bin/seleniumbender

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ examples=0
1818
sketches=0
1919
staging=0
2020
noplugin=0
21+
walkthrough=0
2122

2223
while true; do
2324
case "$1" in
@@ -42,6 +43,8 @@ while true; do
4243
;;
4344
noplugin) noplugin=1
4445
;;
46+
walkthrough) walkthrough=1
47+
;;
4548
-*) echo -e "error: unknown argument: ${1}.\nRun ${app_name} -h."
4649
exit 1
4750
;;
@@ -88,6 +91,33 @@ elif [ "${noplugin}" -eq 1 ]; then
8891
mail -s "Selenium Tests: ${IDENTIFIER} Failed To Run" [email protected] <<< 'Something went wrong with noplugin tests. Please check the logs.'
8992
fi
9093
exit ${RETVAL}
94+
elif [ "${walkthrough}" -eq 1 ]; then
95+
IDENTIFIER="walkthrough"
96+
RETVALS=()
97+
# Linux
98+
export SELENIUM_USER_AGENT='Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 codebender-selenium'
99+
tox tests/walkthrough -- --url=${URL} --source=${SOURCE} --plugin
100+
RETVALS+=($?)
101+
# Windows
102+
export SELENIUM_USER_AGENT='Mozilla/5.0 (Windows NT 6.1; rv:43.0) Gecko/20100101 Firefox/43.0 codebender-selenium'
103+
tox tests/walkthrough -- --url=${URL} --source=${SOURCE} --plugin
104+
RETVALS+=($?)
105+
# MacOSX
106+
export SELENIUM_USER_AGENT='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1; rv:43.0) Gecko/20100101 Firefox/43.0 codebender-selenium'
107+
tox tests/walkthrough -- --url=${URL} --source=${SOURCE} --plugin
108+
RETVALS+=($?)
109+
110+
RETVAL=0
111+
for i in "${RETVALS[@]}"
112+
do
113+
if [ ${i} -ne 0 ]; then
114+
RETVAL=${i}
115+
fi
116+
done
117+
if [ "${RETVAL}" -ne 0 ]; then
118+
mail -s "Selenium Tests: ${IDENTIFIER} Failed To Run" [email protected] <<< 'Something went wrong with noplugin tests. Please check the logs.'
119+
fi
120+
exit ${RETVAL}
91121
fi
92122

93123
DATE=$(date +"%Y-%m-%d") # Get the current date

codebender_testing/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def jsondump(data):
8383
'LOCATE_ELEMENT': 30
8484
}
8585

86-
TESTS_USER_AGENT = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 codebender-selenium'
86+
DEFAULT_USER_AGENT = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 codebender-selenium'
87+
TESTS_USER_AGENT = os.getenv('SELENIUM_USER_AGENT', DEFAULT_USER_AGENT)
8788

8889
# Set up Selenium Webdrivers to be used for selenium tests
8990
def _get_firefox_profile():

tests/walkthrough/__init__py

Whitespace-only changes.

tests/walkthrough/test_walkthrough.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from selenium.webdriver.common.by import By
2+
import pytest
3+
4+
from codebender_testing.config import TESTS_USER_AGENT
5+
from codebender_testing.utils import SeleniumTestCase
6+
from codebender_testing.utils import SELECT_BOARD_SCRIPT
7+
8+
9+
TEST_BOARD = 'Arduino Fio'
10+
11+
12+
class TestUserHome(SeleniumTestCase):
13+
14+
@pytest.fixture(scope="class", autouse=True)
15+
def open_user_home(self, tester_login):
16+
"""Makes sure we are logged in and are at the user home page
17+
performing any of these tests."""
18+
self.get_element(By.CSS_SELECTOR, '#sidebar li:nth-child(4) a').click()
19+
20+
def test_page_1(self):
21+
"""Test page 1"""
22+
assert 'codebender - getting started' in self.driver.title
23+
self.get_element(By.CSS_SELECTOR, '#supported .btn').click()
24+
25+
def test_page_2(self):
26+
"""Test page 2"""
27+
pass
28+
29+
def test_page_3(self):
30+
"""Test page 3"""
31+
if 'Linux' in TESTS_USER_AGENT:
32+
self.get_element(By.CSS_SELECTOR, '#linux-directions .btn:nth-child(2)').click()
33+
self.driver.back()
34+
elif 'Windows' in TESTS_USER_AGENT:
35+
self.get_element(By.CSS_SELECTOR, '#windows-directions .btn:nth-child(2)').click()
36+
self.driver.back()
37+
elif 'Mac' in TESTS_USER_AGENT:
38+
self.get_element(By.CSS_SELECTOR, '#mac-directions .btn:nth-child(2)').click()
39+
self.driver.back()
40+
41+
def test_page_4(self):
42+
"""Test page 4"""
43+
cb_cf_boards = self.get_element(By.CSS_SELECTOR, '#cb_cf_boards')
44+
assert cb_cf_boards.is_displayed()
45+
self.execute_script(SELECT_BOARD_SCRIPT(TEST_BOARD), '$')
46+
cb_cf_ports = self.get_element(By.CSS_SELECTOR, '#cb_cf_ports')
47+
assert cb_cf_ports.is_displayed()
48+
cb_cf_flash_btn = self.get_element(By.CSS_SELECTOR, '#cb_cf_flash_btn')
49+
assert cb_cf_flash_btn.is_displayed()
50+
cb_cf_flash_btn.click()
51+
cb_cf_operation_output = self.get_element(By.CSS_SELECTOR, '#cb_cf_operation_output')
52+
assert cb_cf_operation_output.text.strip() == 'Please select a valid port!'
53+
board_image = self.get_element(By.CSS_SELECTOR, '#arduinoImg')
54+
assert board_image.is_displayed()
55+
56+
def test_page_5(self):
57+
"""Test page 5"""
58+
pass

0 commit comments

Comments
 (0)