Skip to content

Commit 384e02e

Browse files
committed
Update examples
1 parent 3c56e77 commit 384e02e

File tree

5 files changed

+36
-16
lines changed

5 files changed

+36
-16
lines changed

examples/gui_test_runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ def __init__(self, master):
6363
fg="red").pack()
6464
self.title7 = Label(
6565
frame,
66-
text="Run a Failing Test with Delayed Asserts:",
66+
text="Run a Failing Test with Deferred Asserts:",
6767
fg="blue").pack()
6868
self.run7 = Button(
6969
frame, command=self.run_7,
70-
text=("pytest test_delayed_asserts.py --browser=chrome"),
70+
text=("pytest test_deferred_asserts.py --browser=chrome"),
7171
fg="red").pack()
7272
self.end_title = Label(frame, text="", fg="black").pack()
7373
self.quit = Button(frame, text="QUIT", command=frame.quit).pack()
@@ -98,7 +98,7 @@ def run_6(self):
9898

9999
def run_7(self):
100100
os.system(
101-
'pytest test_delayed_asserts.py --browser=chrome')
101+
'pytest test_deferred_asserts.py --browser=chrome')
102102

103103

104104
if __name__ == "__main__":

examples/handle_alert_test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ class MyTestClass(BaseCase):
66
def test_alerts(self):
77
self.open("about:blank")
88
self.execute_script('window.alert("ALERT!!!")')
9-
self.sleep(1.2) # Not needed (Lets you see the alert pop up)
10-
self.wait_for_and_accept_alert()
11-
self.sleep(0.8) # Not needed (Lets you see the alert go away)
9+
self.sleep(1) # Not needed (Lets you see the alert pop up)
10+
self.accept_alert()
11+
self.sleep(1) # Not needed (Lets you see the alert go away)
1212
self.execute_script('window.prompt("My Prompt","defaultText");')
13-
self.sleep(1.2) # Not needed (Lets you see the alert pop up)
14-
alert = self.wait_for_and_switch_to_alert(timeout=2)
15-
self.assert_equal(alert.text, "My Prompt") # Not the input field
16-
self.wait_for_and_dismiss_alert()
17-
self.sleep(0.8) # Not needed (Lets you see the alert go away)
13+
self.sleep(1) # Not needed (Lets you see the alert pop up)
14+
alert = self.switch_to_alert()
15+
self.assert_equal(alert.text, "My Prompt") # Not input field
16+
self.dismiss_alert()
17+
self.sleep(1) # Not needed (Lets you see the alert go away)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pytest
2+
from seleniumbase import BaseCase
3+
4+
5+
@pytest.mark.offline # Can be run with: "pytest -m offline"
6+
class OfflineTestClass(BaseCase):
7+
8+
def test_alerts(self):
9+
self.open("data:,")
10+
self.execute_script('window.alert("ALERT!!!")')
11+
self.sleep(1) # Not needed (Lets you see the alert pop up)
12+
self.accept_alert()
13+
self.sleep(1) # Not needed (Lets you see the alert go away)
14+
self.execute_script('window.prompt("My Prompt","defaultText");')
15+
self.sleep(1) # Not needed (Lets you see the alert pop up)
16+
alert = self.switch_to_alert()
17+
self.assert_equal(alert.text, "My Prompt") # Not input field
18+
self.dismiss_alert()
19+
self.sleep(1) # Not needed (Lets you see the alert go away)

examples/offline_examples/test_demo_page.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
class OfflineTestClass(BaseCase):
88

99
def test_demo_page(self):
10-
# Load a local html file into the browser
11-
dir_name = os.path.dirname(os.path.abspath(__file__))
12-
self.load_html_file(dir_name + "/demo_page.html")
10+
# Load a local html file into the web browser
11+
dir_path = os.path.dirname(os.path.abspath(__file__))
12+
file_path = dir_path + "/demo_page.html"
13+
self.load_html_file(file_path)
1314

1415
# Assert the title of the current web page
1516
self.assert_title("Web Testing Page")

examples/translations/french_test_1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ def test_exemple_1(self):
99
self.vérifier_texte("Wikipédia") # noqa
1010
self.vérifier_élément('[title="Visiter la page d’accueil"]')
1111
self.modifier_texte("#searchInput", "Crème brûlée")
12-
self.cliquez_sur("#searchButton")
12+
self.cliquer("#searchButton")
1313
self.vérifier_texte("Crème brûlée", "#firstHeading")
1414
self.vérifier_élément('img[alt*="Crème brûlée"]')
1515
self.modifier_texte("#searchInput", "Jardin des Tuileries")
16-
self.cliquez_sur("#searchButton")
16+
self.cliquer("#searchButton")
1717
self.vérifier_texte("Jardin des Tuileries", "#firstHeading")
1818
self.vérifier_élément('img[alt*="Jardin des Tuileries"]')
1919
self.retour()

0 commit comments

Comments
 (0)