Skip to content

Commit ee08daf

Browse files
author
Brandon Duffany
committed
Add sketch verify test
1 parent 1de527a commit ee08daf

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

codebender_testing/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
from selenium import webdriver
22

33

4+
# URL of the site to be used for testing
45
BASE_URL = "http://localhost"
56

7+
# Selenium Webdrivers to be used for selenium tests
68
WEBDRIVERS = {
79
"firefox": webdriver.Firefox,
810
"chrome": webdriver.Chrome
911
}
1012

13+
# Credentials to use when logging into the site via selenium
1114
TEST_CREDENTIALS = {
1215
"username": "tester",
1316
"password": "testerPASS"
1417
}
18+
19+
# How long to wait before we give up on the 'verify' command (in seconds)
20+
VERIFY_TIMEOUT = 10
21+

codebender_testing/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def open(self, url=None):
3535
# url specifies an absolute path.
3636
return self.driver.get(url)
3737
else:
38+
url = url.lstrip('/')
3839
return self.driver.get("%s/%s" % (BASE_URL, url))
3940

4041

tests/home/test_home.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ def test_navigate_home(self):
77
self.open("/")
88
assert "Codebender" in self.driver.title
99

10-
#tests login features
1110
def test_login(self):
11+
"""Test to ensure the login box is displayed"""
1212
driver = self.driver
1313
self.open("/")
1414
login_elem = driver.find_element_by_id("login_btn") #finds login button

tests/sketch/__init__.py

Whitespace-only changes.

tests/sketch/test_sketch.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from selenium.webdriver.common.by import By
2+
from selenium.webdriver.common.keys import Keys
3+
from selenium.webdriver.support import expected_conditions
4+
from selenium.webdriver.support.ui import WebDriverWait
5+
6+
from codebender_testing.config import VERIFY_TIMEOUT
7+
from codebender_testing.utils import logged_in
8+
from codebender_testing.utils import SeleniumTestCase
9+
10+
11+
class TestSketch(SeleniumTestCase):
12+
13+
@logged_in
14+
def test_verify_code(self):
15+
test_project_link = self.driver.find_element_by_link_text('test_project')
16+
test_project_link.send_keys(Keys.ENTER)
17+
18+
compile_button = self.driver.find_element_by_id("compile")
19+
compile_button.click()
20+
21+
try:
22+
WebDriverWait(self.driver, VERIFY_TIMEOUT).until(
23+
expected_conditions.text_to_be_present_in_element(
24+
(By.ID, "operation_output"), "Verification Successful!")
25+
)
26+
except:
27+
raise
28+
# assert False, "Test timed out"
29+
30+
assert output.text == "Verification Successful!"
31+

0 commit comments

Comments
 (0)