Skip to content

Commit f1e6622

Browse files
authored
Merge pull request #980 from seleniumbase/visual-testing-improvements
Make improvements to SeleniumBase Visual Testing
2 parents 828e95d + eab3bad commit f1e6622

File tree

6 files changed

+63
-29
lines changed

6 files changed

+63
-29
lines changed

help_docs/method_summary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ self.switch_to_alert(timeout=None)
654654

655655
############
656656

657-
self.check_window(name="default", level=0, baseline=False)
657+
self.check_window(name="default", level=0, baseline=False, check_domain=True)
658658

659659
############
660660

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ packaging>=21.0;python_version>="3.6"
55
typing-extensions>=3.10.0.2
66
setuptools>=44.1.1;python_version<"3.5"
77
setuptools>=50.3.2;python_version>="3.5" and python_version<"3.6"
8-
setuptools>=58.0.0;python_version>="3.6"
8+
setuptools>=58.0.2;python_version>="3.6"
99
setuptools-scm==5.0.2;python_version<"3.6"
1010
setuptools-scm>=6.3.1;python_version>="3.6"
1111
tomli>=1.2.1;python_version>="3.6"
@@ -83,7 +83,7 @@ ipython==5.10.0;python_version<"3.5"
8383
ipython==7.9.0;python_version>="3.5" and python_version<"3.6"
8484
ipython==7.16.1;python_version>="3.6" and python_version<"3.7"
8585
ipython==7.27.0;python_version>="3.7"
86-
matplotlib-inline==0.1.2;python_version>="3.7"
86+
matplotlib-inline==0.1.3;python_version>="3.7"
8787
colorama==0.4.4
8888
platformdirs==2.0.2;python_version<"3.6"
8989
platformdirs==2.3.0;python_version>="3.6"

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "1.65.2"
2+
__version__ = "1.65.3"

seleniumbase/fixtures/base_case.py

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8053,12 +8053,28 @@ def __assert_eq(self, *args, **kwargs):
80538053
lines = str_e.split("\n")
80548054
countdown = 3
80558055
countdown_on = False
8056+
first_differing = False
8057+
skip_lines = False
80568058
for line in lines:
80578059
if countdown_on:
8058-
minified_exception += line + "\n"
8060+
if not skip_lines:
8061+
minified_exception += line + "\n"
80598062
countdown = countdown - 1
80608063
if countdown == 0:
80618064
countdown_on = False
8065+
skip_lines = False
8066+
elif line.startswith("First differing"):
8067+
first_differing = True
8068+
countdown_on = True
8069+
countdown = 3
8070+
minified_exception += line + "\n"
8071+
elif line.startswith("First list"):
8072+
countdown_on = True
8073+
countdown = 3
8074+
if not first_differing:
8075+
minified_exception += line + "\n"
8076+
else:
8077+
skip_lines = True
80628078
elif line.startswith("F"):
80638079
countdown_on = True
80648080
countdown = 3
@@ -8072,7 +8088,9 @@ def __assert_eq(self, *args, **kwargs):
80728088
if minified_exception:
80738089
raise Exception(minified_exception)
80748090

8075-
def check_window(self, name="default", level=0, baseline=False):
8091+
def check_window(
8092+
self, name="default", level=0, baseline=False, check_domain=True
8093+
):
80768094
"""*** Automated Visual Testing with SeleniumBase ***
80778095
80788096
The first time a test calls self.check_window() for a unique "name"
@@ -8094,8 +8112,8 @@ def check_window(self, name="default", level=0, baseline=False):
80948112
HTML tags of the latest window to the one from the initial run.
80958113
Here's how the level system works:
80968114
* level=0 ->
8097-
DRY RUN ONLY - Will perform a comparison to the baseline, and
8098-
print out any differences that are found, but
8115+
DRY RUN ONLY - Will perform comparisons to the baseline (and
8116+
print out any differences that are found) but
80998117
won't fail the test even if differences exist.
81008118
* level=1 ->
81018119
HTML tags are compared to tags_level1.txt
@@ -8120,7 +8138,8 @@ def check_window(self, name="default", level=0, baseline=False):
81208138
need to reset the baseline to prevent unnecessary failures.
81218139
81228140
self.check_window() will fail with "Page Domain Mismatch Failure"
8123-
if the page domain doesn't match the domain of the baseline.
8141+
if the page domain doesn't match the domain of the baseline,
8142+
unless "check_domain" is set to False when calling check_window().
81248143
81258144
If you want to use self.check_window() to compare a web page to
81268145
a later version of itself from within the same test run, you can
@@ -8235,7 +8254,7 @@ def check_window(self, name="default", level=0, baseline=False):
82358254
f.close()
82368255

82378256
domain_fail = (
8238-
"\nPage Domain Mismatch Failure: "
8257+
"\n*\nPage Domain Mismatch Failure: "
82398258
"Current Page Domain doesn't match the Page Domain of the "
82408259
"Baseline! Can't compare two completely different sites! "
82418260
"Run with --visual_baseline to reset the baseline!"
@@ -8255,28 +8274,42 @@ def check_window(self, name="default", level=0, baseline=False):
82558274

82568275
page_domain = self.get_domain_url(page_url)
82578276
page_data_domain = self.get_domain_url(page_url_data)
8258-
unittest.TestCase.maxDiff = 1000
8259-
if level != 0:
8277+
unittest.TestCase.maxDiff = 3200
8278+
if level != 0 and check_domain:
82608279
self.assertEqual(page_data_domain, page_domain, domain_fail)
8261-
unittest.TestCase.maxDiff = None
8280+
unittest.TestCase.maxDiff = 6400 # Use `None` for no limit
82628281
if level == 3:
82638282
self.__assert_eq(level_3_data, level_3, level_3_failure)
8283+
unittest.TestCase.maxDiff = 3200
82648284
if level == 2:
82658285
self.__assert_eq(level_2_data, level_2, level_2_failure)
8266-
unittest.TestCase.maxDiff = 1000
82678286
if level == 1:
82688287
self.__assert_eq(level_1_data, level_1, level_1_failure)
8269-
unittest.TestCase.maxDiff = None
8288+
unittest.TestCase.maxDiff = 6400 # Use `None` for no limit
82708289
if level == 0:
82718290
try:
8272-
unittest.TestCase.maxDiff = 1000
8273-
self.assertEqual(
8274-
page_domain, page_data_domain, domain_fail
8275-
)
8276-
unittest.TestCase.maxDiff = None
8291+
unittest.TestCase.maxDiff = 3200
8292+
if check_domain:
8293+
self.assertEqual(
8294+
page_domain, page_data_domain, domain_fail
8295+
)
8296+
try:
8297+
self.__assert_eq(
8298+
level_1_data, level_1, level_1_failure
8299+
)
8300+
except Exception as e:
8301+
print(e)
8302+
try:
8303+
self.__assert_eq(
8304+
level_2_data, level_2, level_2_failure
8305+
)
8306+
except Exception as e:
8307+
print(e)
8308+
unittest.TestCase.maxDiff = 6400 # Use `None` for no limit
82778309
self.__assert_eq(level_3_data, level_3, level_3_failure)
82788310
except Exception as e:
82798311
print(e) # Level-0 Dry Run (Only print the differences)
8312+
unittest.TestCase.maxDiff = None # Reset unittest.TestCase.maxDiff
82808313

82818314
############
82828315

seleniumbase/fixtures/constants.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,6 @@ class HighCharts:
232232
)
233233

234234

235-
class TourColor:
236-
# theme_color = "#f26721" # Orange
237-
# hover_color = "#db5409" # Darker Orange
238-
theme_color = "#2167e2" # Blue
239-
hover_color = "#0954cb" # Darker Blue
240-
241-
242235
class BootstrapTour:
243236
VER = "0.12.0"
244237
MIN_CSS = (
@@ -281,6 +274,14 @@ class IntroJS:
281274
MIN_JS = "https://unpkg.com/intro.js@%s/minified/intro.min.js" % VER
282275

283276

277+
class TourColor:
278+
"""Used for button colors in IntroJS Tours"""
279+
# theme_color = "#f26721" # Orange
280+
# hover_color = "#db5409" # Darker Orange
281+
theme_color = "#458bca" # Blue
282+
hover_color = "#336aa5" # Darker Blue
283+
284+
284285
class JqueryConfirm:
285286
VER = "3.3.4"
286287
MIN_CSS = (

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
"typing-extensions>=3.10.0.2",
122122
'setuptools>=44.1.1;python_version<"3.5"',
123123
'setuptools>=50.3.2;python_version>="3.5" and python_version<"3.6"',
124-
'setuptools>=58.0.0;python_version>="3.6"',
124+
'setuptools>=58.0.2;python_version>="3.6"',
125125
'setuptools-scm==5.0.2;python_version<"3.6"',
126126
'setuptools-scm>=6.3.1;python_version>="3.6"',
127127
'tomli>=1.2.1;python_version>="3.6"',
@@ -199,7 +199,7 @@
199199
'ipython==7.9.0;python_version>="3.5" and python_version<"3.6"',
200200
'ipython==7.16.1;python_version>="3.6" and python_version<"3.7"',
201201
'ipython==7.27.0;python_version>="3.7"', # Requires matplotlib-inline
202-
'matplotlib-inline==0.1.2;python_version>="3.7"', # ipython needs this
202+
'matplotlib-inline==0.1.3;python_version>="3.7"', # ipython needs this
203203
"colorama==0.4.4",
204204
'platformdirs==2.0.2;python_version<"3.6"',
205205
'platformdirs==2.3.0;python_version>="3.6"',

0 commit comments

Comments
 (0)