@@ -8053,12 +8053,28 @@ def __assert_eq(self, *args, **kwargs):
8053
8053
lines = str_e .split ("\n " )
8054
8054
countdown = 3
8055
8055
countdown_on = False
8056
+ first_differing = False
8057
+ skip_lines = False
8056
8058
for line in lines :
8057
8059
if countdown_on :
8058
- minified_exception += line + "\n "
8060
+ if not skip_lines :
8061
+ minified_exception += line + "\n "
8059
8062
countdown = countdown - 1
8060
8063
if countdown == 0 :
8061
8064
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
8062
8078
elif line .startswith ("F" ):
8063
8079
countdown_on = True
8064
8080
countdown = 3
@@ -8072,7 +8088,9 @@ def __assert_eq(self, *args, **kwargs):
8072
8088
if minified_exception :
8073
8089
raise Exception (minified_exception )
8074
8090
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
+ ):
8076
8094
"""*** Automated Visual Testing with SeleniumBase ***
8077
8095
8078
8096
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):
8094
8112
HTML tags of the latest window to the one from the initial run.
8095
8113
Here's how the level system works:
8096
8114
* 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
8099
8117
won't fail the test even if differences exist.
8100
8118
* level=1 ->
8101
8119
HTML tags are compared to tags_level1.txt
@@ -8120,7 +8138,8 @@ def check_window(self, name="default", level=0, baseline=False):
8120
8138
need to reset the baseline to prevent unnecessary failures.
8121
8139
8122
8140
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().
8124
8143
8125
8144
If you want to use self.check_window() to compare a web page to
8126
8145
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):
8235
8254
f .close ()
8236
8255
8237
8256
domain_fail = (
8238
- "\n Page Domain Mismatch Failure: "
8257
+ "\n * \ n Page Domain Mismatch Failure: "
8239
8258
"Current Page Domain doesn't match the Page Domain of the "
8240
8259
"Baseline! Can't compare two completely different sites! "
8241
8260
"Run with --visual_baseline to reset the baseline!"
@@ -8255,28 +8274,42 @@ def check_window(self, name="default", level=0, baseline=False):
8255
8274
8256
8275
page_domain = self .get_domain_url (page_url )
8257
8276
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 :
8260
8279
self .assertEqual (page_data_domain , page_domain , domain_fail )
8261
- unittest .TestCase .maxDiff = None
8280
+ unittest .TestCase .maxDiff = 6400 # Use ` None` for no limit
8262
8281
if level == 3 :
8263
8282
self .__assert_eq (level_3_data , level_3 , level_3_failure )
8283
+ unittest .TestCase .maxDiff = 3200
8264
8284
if level == 2 :
8265
8285
self .__assert_eq (level_2_data , level_2 , level_2_failure )
8266
- unittest .TestCase .maxDiff = 1000
8267
8286
if level == 1 :
8268
8287
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
8270
8289
if level == 0 :
8271
8290
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
8277
8309
self .__assert_eq (level_3_data , level_3 , level_3_failure )
8278
8310
except Exception as e :
8279
8311
print (e ) # Level-0 Dry Run (Only print the differences)
8312
+ unittest .TestCase .maxDiff = None # Reset unittest.TestCase.maxDiff
8280
8313
8281
8314
############
8282
8315
0 commit comments