From 2d09587968a86bb7bdfe0eaf47df3c9f41eae6a8 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Fri, 8 Oct 2021 23:55:09 -0400 Subject: [PATCH] Update examples --- examples/test_demo_site.py | 10 ++++++++-- seleniumbase/console_scripts/sb_mkdir.py | 10 +++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/examples/test_demo_site.py b/examples/test_demo_site.py index 74deecec..f1cbf1b5 100755 --- a/examples/test_demo_site.py +++ b/examples/test_demo_site.py @@ -22,9 +22,10 @@ class DemoSiteTests(BaseCase): # Verify that a hover dropdown link changes page text self.assert_text("Automation Practice", "h3") try: - self.hover_and_click("#myDropdown", "#dropOption2") + self.hover_and_click( + "#myDropdown", "#dropOption2", timeout=2) except Exception: - # If the user moves the mouse while the test runs + # If a human moves the mouse while the test runs self.js_click("#dropOption2") self.assert_text("Link Two Selected", "h3") @@ -107,6 +108,11 @@ class DemoSiteTests(BaseCase): # Highlight a page element (Also asserts visibility) self.highlight("h2") + # Actions with Demo Mode enabled + self.demo_mode = True + self.type("input", "Have a Nice Day!") + self.assert_text("SeleniumBase", "h2") + # Assert no broken links (Can be slow if many links) # self.assert_no_404_errors() diff --git a/seleniumbase/console_scripts/sb_mkdir.py b/seleniumbase/console_scripts/sb_mkdir.py index 9ba7a15a..3ba7fb4d 100755 --- a/seleniumbase/console_scripts/sb_mkdir.py +++ b/seleniumbase/console_scripts/sb_mkdir.py @@ -337,7 +337,12 @@ def main(): data.append(' self.type("textarea.area1", "Testing Time!\\n")') data.append(' self.type(\'[name="preText2"]\', "Typing Text!")') data.append(' self.assert_text("Automation Practice", "h3")') - data.append(' self.hover_and_click("#myDropdown", "#dropOption2")') + data.append(" try:") + data.append(" self.hover_and_click(") + data.append(' "#myDropdown", "#dropOption2", timeout=2)') + data.append(" except Exception:") + data.append(" # If a human moves the mouse while the test runs") + data.append(' self.js_click("#dropOption2")') data.append(' self.assert_text("Link Two Selected", "h3")') data.append(' self.assert_text("This Text is Green", "#pText")') data.append(' self.click("#myButton")') @@ -393,6 +398,9 @@ def main(): data.append(' self.click_link("SeleniumBase Demo Page")') data.append(' self.assert_exact_text("Demo Page", "h1")') data.append(' self.highlight("h2")') + data.append(" self.demo_mode = True") + data.append(' self.type("input", "Have a Nice Day!")') + data.append(' self.assert_text("SeleniumBase", "h2")') data.append("") file_path = "%s/%s" % (dir_name, "test_demo_site.py") file = codecs.open(file_path, "w+", "utf-8")