Skip to content

Commit 4397bbb

Browse files
committed
Update examples
1 parent f11c25b commit 4397bbb

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

examples/offline_examples/test_request_fixture.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22

33

4+
# Use the pytest "request" fixture to get the "sb" fixture (no class)
45
@pytest.mark.offline
56
def test_request_fixture(request):
67
sb = request.getfixturevalue('sb')
@@ -10,3 +11,16 @@ def test_request_fixture(request):
1011
sb.type("input", "Goodbye")
1112
sb.click("body p")
1213
sb.tearDown()
14+
15+
16+
# Use the pytest "request" fixture to get the "sb" fixture (in class)
17+
@pytest.mark.offline
18+
class Test_Request_Fixture():
19+
def test_request_fixture_in_class(self, request):
20+
sb = request.getfixturevalue('sb')
21+
sb.open("data:text/html,<p>Hello<br><input></p>")
22+
sb.assert_element("html > body")
23+
sb.assert_text("Hello", "body p")
24+
sb.type("input", "Goodbye")
25+
sb.click("body p")
26+
sb.tearDown()

examples/test_request_sb_fixture.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Use the pytest "request" fixture to get the "sb" fixture (no class)
12
def test_request_sb_fixture(request):
23
sb = request.getfixturevalue('sb')
34
sb.open("https://seleniumbase.io/demo_page")
@@ -6,3 +7,16 @@ def test_request_sb_fixture(request):
67
sb.type("#myTextarea", "This is me")
78
sb.click("#myButton")
89
sb.tearDown()
10+
11+
12+
# Use the pytest "request" fixture to get the "sb" fixture (in class)
13+
class Test_Request_Fixture():
14+
def test_request_sb_fixture_in_class(self, request):
15+
sb = request.getfixturevalue('sb')
16+
sb.open("https://seleniumbase.io/demo_page")
17+
sb.assert_element("input#myTextInput")
18+
sb.type("#myTextarea", "Automated")
19+
sb.assert_text("This Text is Green", "#pText")
20+
sb.click("#myButton")
21+
sb.assert_text("This Text is Purple", "#pText")
22+
sb.tearDown()

examples/test_sb_fixture.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
# "sb" pytest fixture test in a method with no class
42
def test_sb_fixture_with_no_class(sb):
53
sb.open("https://google.com/ncr")

0 commit comments

Comments
 (0)