SeleniumBase/examples/test_suite.py

32 lines
1.1 KiB
Python
Raw Normal View History

2021-05-06 09:06:24 +08:00
""" This test suite contains 2 passing tests and 2 failing tests. """
2016-05-10 12:10:16 +08:00
2018-12-11 15:01:57 +08:00
import pytest
from seleniumbase import BaseCase
class MyTestSuite(BaseCase):
def test_1(self):
2020-08-08 13:21:28 +08:00
self.open("https://xkcd.com/1664/")
self.assert_text("Mycology", "div#ctitle", timeout=4)
for p in range(3):
self.click('a[rel="next"]')
2020-08-08 13:21:28 +08:00
self.assert_text("Algorithms", "div#ctitle", timeout=4)
2018-12-11 15:01:57 +08:00
@pytest.mark.expected_failure
def test_2(self):
2021-03-07 12:42:08 +08:00
print("\n(This test should fail)")
self.open("https://xkcd.com/1675/")
raise Exception("FAKE EXCEPTION: This test fails on purpose.")
def test_3(self):
self.open("https://xkcd.com/1406/")
2020-08-08 13:21:28 +08:00
self.assert_text("Universal Converter Box", "div#ctitle", timeout=4)
self.open("https://xkcd.com/608/")
2020-08-08 13:21:28 +08:00
self.assert_text("Form", "div#ctitle", timeout=4)
2018-12-11 15:01:57 +08:00
@pytest.mark.expected_failure
def test_4(self):
2021-03-07 12:42:08 +08:00
print("\n(This test should fail)")
self.open("https://xkcd.com/1670/")
2018-12-11 15:01:57 +08:00
self.assert_element("FakeElement.DoesNotExist", timeout=0.5)