From 46529b61bf0c03bcdad40371364e45a08bfc5b8c Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Wed, 21 Apr 2021 22:54:42 -0400 Subject: [PATCH] Update example tests --- examples/chart_maker/chart_presentation.py | 6 +++--- examples/chart_maker/test_save_chart.py | 6 +++--- examples/migration/__init__.py | 0 examples/migration/protractor/__init__.py | 0 examples/migration/protractor/example_test.py | 2 +- .../migration/protractor/mat_paginator_test.py | 6 +++--- examples/raw_parameter_script.py | 5 ++++- examples/swag_labs_suite.py | 18 ------------------ 8 files changed, 14 insertions(+), 29 deletions(-) create mode 100755 examples/migration/__init__.py create mode 100755 examples/migration/protractor/__init__.py diff --git a/examples/chart_maker/chart_presentation.py b/examples/chart_maker/chart_presentation.py index d79cd7a9..910020be 100755 --- a/examples/chart_maker/chart_presentation.py +++ b/examples/chart_maker/chart_presentation.py @@ -12,19 +12,19 @@ class ChartMakerPresentation(BaseCase): self.add_data_point("Failed", 1, color="#f1888f") self.add_slide("

Pie Chart

" + self.extract_chart()) - self.create_bar_chart(title="Language", libs=False, legend=False) + self.create_bar_chart(title="Language", legend=False) self.add_data_point("Python", 33, color="Orange") self.add_data_point("JavaScript", 27, color="Teal") self.add_data_point("HTML + CSS", 21, color="Purple") self.add_slide("

Bar Chart

" + self.extract_chart()) - self.create_column_chart(title="Colors", libs=False, legend=False) + self.create_column_chart(title="Colors", legend=False) self.add_data_point("Red", 10, color="Red") self.add_data_point("Green", 25, color="Green") self.add_data_point("Blue", 15, color="Blue") self.add_slide("

Column Chart

" + self.extract_chart()) - self.create_line_chart(title="Last Week's Data", libs=False) + self.create_line_chart(title="Last Week's Data") self.add_data_point("Sun", 5) self.add_data_point("Mon", 10) self.add_data_point("Tue", 20) diff --git a/examples/chart_maker/test_save_chart.py b/examples/chart_maker/test_save_chart.py index 7c401f83..b1e4f9a9 100755 --- a/examples/chart_maker/test_save_chart.py +++ b/examples/chart_maker/test_save_chart.py @@ -10,19 +10,19 @@ class MyChartMakerClass(BaseCase): self.add_data_point("Failed", 1, color="#f1888f") self.save_chart(filename="pie_chart.html") - self.create_bar_chart(title="Bar Chart", libs=False) + self.create_bar_chart(title="Bar Chart") self.add_data_point("Python", 33, color="Orange") self.add_data_point("JavaScript", 27, color="Teal") self.add_data_point("HTML + CSS", 21, color="Purple") self.save_chart(filename="bar_chart.html") - self.create_column_chart(title="Column Chart", libs=False) + self.create_column_chart(title="Column Chart") self.add_data_point("Red", 10, color="Red") self.add_data_point("Green", 25, color="Green") self.add_data_point("Blue", 15, color="Blue") self.save_chart(filename="column_chart.html") - self.create_line_chart(title="Line Chart", libs=False) + self.create_line_chart(title="Line Chart") self.add_data_point("Sun", 5) self.add_data_point("Mon", 10) self.add_data_point("Tue", 20) diff --git a/examples/migration/__init__.py b/examples/migration/__init__.py new file mode 100755 index 00000000..e69de29b diff --git a/examples/migration/protractor/__init__.py b/examples/migration/protractor/__init__.py new file mode 100755 index 00000000..e69de29b diff --git a/examples/migration/protractor/example_test.py b/examples/migration/protractor/example_test.py index d51973d3..7ff0dc85 100644 --- a/examples/migration/protractor/example_test.py +++ b/examples/migration/protractor/example_test.py @@ -6,7 +6,7 @@ class AngularJSHomePageTests(BaseCase): def test_greet_user(self): self.open("http://www.angularjs.org") self.type('[ng-model="yourName"]', "Julie") - self.assert_text("Hello Julie!", "h1.ng-binding") + self.assert_exact_text("Hello Julie!", "h1.ng-binding") def test_todo_list(self): self.open("http://www.angularjs.org") diff --git a/examples/migration/protractor/mat_paginator_test.py b/examples/migration/protractor/mat_paginator_test.py index 716f56ed..faeca76b 100644 --- a/examples/migration/protractor/mat_paginator_test.py +++ b/examples/migration/protractor/mat_paginator_test.py @@ -8,11 +8,11 @@ class AngularMaterialPaginatorTests(BaseCase): self.assert_element(".mat-button-wrapper > .mat-icon") # Verify navigation to the next page self.click('button[aria-label="Next page"]') - self.assert_text("11 – 20 of 100", ".mat-paginator-range-label") + self.assert_exact_text("11 – 20 of 100", ".mat-paginator-range-label") # Verify navigation to the previous page self.click('button[aria-label="Previous page"]') - self.assert_text("1 – 10 of 100", ".mat-paginator-range-label") + self.assert_exact_text("1 – 10 of 100", ".mat-paginator-range-label") # Verify changed list length to 5 items per page self.click("mat-select > div") self.click("mat-option > .mat-option-text") - self.assert_text("1 – 5 of 100", ".mat-paginator-range-label") + self.assert_exact_text("1 – 5 of 100", ".mat-paginator-range-label") diff --git a/examples/raw_parameter_script.py b/examples/raw_parameter_script.py index 951d2083..9cee91cc 100755 --- a/examples/raw_parameter_script.py +++ b/examples/raw_parameter_script.py @@ -15,6 +15,7 @@ specific needs, you may need to call SeleniumBase commands without using Pytest, and this example shows you how. """ +pure_python = False try: # Running with Pytest / (Finds test methods to run using autodiscovery) # Example run command: "pytest raw_parameter_script.py" @@ -23,8 +24,10 @@ try: except (ImportError, ValueError): # Running with pure Python OR from a Python interactive interpreter # Example run command: "python raw_parameter_script.py" - from my_first_test import MyTestClass # (relative imports DON'T work) + from my_first_test import MyTestClass # (relative imports do not work) + pure_python = True +if pure_python: sb = MyTestClass("test_basics") sb.browser = "chrome" sb.headless = False diff --git a/examples/swag_labs_suite.py b/examples/swag_labs_suite.py index 12d39c5d..e438f02e 100755 --- a/examples/swag_labs_suite.py +++ b/examples/swag_labs_suite.py @@ -76,24 +76,6 @@ class SwagLabsTests(BaseCase): self.click("button#continue-shopping") self.assert_element_absent("span.shopping_cart_badge") - @parameterized.expand([ - ["standard_user"], - ["problem_user"], - ]) - def test_swag_labs_visual_regressions(self, username): - """ This test checks for visual regressions on the Swag Labs page. - This test is parameterized on the login user. """ - self.login_to_swag_labs(username="standard_user") - self.js_click("a#reset_sidebar_link") - self.js_click("a#logout_sidebar_link") - self.login_to_swag_labs(username="standard_user") - self.check_window(baseline=True) - self.js_click("a#logout_sidebar_link") - if username == "problem_user": - print("\n(This test should fail)") - self.login_to_swag_labs(username=username) - self.check_window(level=3) - def tearDown(self): self.save_teardown_screenshot() # Reset App State and Logout if the controls are present