SeleniumBase/examples/time_limit_test.py

19 lines
727 B
Python
Raw Normal View History

""" This test fails on purpose to demonstrate the time-limit feature
2020-05-30 06:25:55 +08:00
for tests that run longer than the time limit specified (seconds).
The time-limit clock starts after the browser has fully launched,
which is after pytest starts it's own internal clock for tests.
Usage: (inside tests) => self.set_time_limit(SECONDS)
Usage: (command-line) => --time-limit=SECONDS """
import pytest
from seleniumbase import BaseCase
2021-03-11 06:27:52 +08:00
class TimeLimitTests(BaseCase):
@pytest.mark.expected_failure
def test_time_limit_feature(self):
2020-05-30 06:25:55 +08:00
self.set_time_limit(5) # Fail test if time exceeds 5 seconds
self.open("https://xkcd.com/1658/")
2021-03-07 12:42:08 +08:00
print("\n(This test should fail)")
self.sleep(7)