Skip to content

Commit 73c4270

Browse files
committed
Update example tests
1 parent a71ee7d commit 73c4270

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

examples/timeout_test.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
""" This test fails on purpose to demonstrate the time-limit feature
2-
for tests that run longer than the time limit specified in seconds.
3-
Usage: (inside tests) -> self.set_time_limit(SECONDS) """
2+
for tests that run longer than the time limit specified (seconds).
3+
The time-limit clock starts after the browser has fully launched,
4+
which is after pytest starts it's own internal clock for tests.
5+
Usage: (inside tests) => self.set_time_limit(SECONDS)
6+
Usage: (command-line) => --time-limit=SECONDS """
47

58
import pytest
69
from seleniumbase import BaseCase
@@ -10,6 +13,6 @@ class MyTestClass(BaseCase):
1013

1114
@pytest.mark.expected_failure
1215
def test_time_limit_feature(self):
13-
self.set_time_limit(6) # Test fails if run-time exceeds limit
16+
self.set_time_limit(5) # Fail test if time exceeds 5 seconds
1417
self.open("https://xkcd.com/1658/")
1518
self.sleep(7)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from seleniumbase import BaseCase
2+
3+
4+
class MyTestClass(BaseCase):
5+
6+
def test_example_1(self):
7+
url = "https://store.xkcd.com/collections/everything"
8+
self.open(url)
9+
self.update_text("input.search-input", "xkcd book\n")
10+
self.assert_exact_text("xkcd: volume 0", "h3")
11+
self.click("li.checkout-link")
12+
self.assert_text("Shopping Cart", "#page-title")
13+
self.assert_element("div#umbrella")
14+
self.open("https://xkcd.com/353/")
15+
self.assert_title("xkcd: Python")
16+
self.assert_element('img[alt="Python"]')
17+
self.click('a[rel="license"]')
18+
self.assert_text("back to this page")
19+
self.go_back()
20+
self.click("link=About")
21+
self.assert_text("xkcd.com", "h2")

0 commit comments

Comments
 (0)