66from seleniumbase .config import settings
77from seleniumbase .core .style_sheet import style
88from seleniumbase .fixtures import page_actions
9+ from seleniumbase import drivers
910
1011LATEST_REPORT_DIR = settings .LATEST_REPORT_DIR
1112ARCHIVE_DIR = settings .REPORT_ARCHIVE_DIR
1213HTML_REPORT = settings .HTML_REPORT
1314RESULTS_TABLE = settings .RESULTS_TABLE
15+ DRIVER_DIR = os .path .dirname (os .path .realpath (drivers .__file__ ))
16+ PLATFORM = sys .platform
17+ LOCAL_CHROMEDRIVER = None
18+ LOCAL_GECKODRIVER = None
19+ if "darwin" in PLATFORM or "linux" in PLATFORM :
20+ LOCAL_CHROMEDRIVER = DRIVER_DIR + '/chromedriver'
21+ LOCAL_GECKODRIVER = DRIVER_DIR + '/geckodriver'
22+ elif "win32" in PLATFORM or "win64" in PLATFORM or "x64" in PLATFORM :
23+ LOCAL_CHROMEDRIVER = DRIVER_DIR + '/chromedriver.exe'
24+ LOCAL_GECKODRIVER = DRIVER_DIR + '/geckodriver.exe'
1425
1526
1627def get_timestamp ():
@@ -35,8 +46,9 @@ def process_successes(test, test_count, duration):
3546def process_failures (test , test_count , browser_type , duration ):
3647 bad_page_image = "failure_%s.png" % test_count
3748 bad_page_data = "failure_%s.txt" % test_count
38- page_actions .save_screenshot (
39- test .driver , bad_page_image , folder = LATEST_REPORT_DIR )
49+ screenshot_path = "%s/%s" % (LATEST_REPORT_DIR , bad_page_image )
50+ with open (screenshot_path , "wb" ) as file :
51+ file .write (test ._last_page_screenshot )
4052 page_actions .save_test_failure_data (
4153 test .driver , bad_page_data , browser_type , folder = LATEST_REPORT_DIR )
4254 exc_info = '(Unknown Failure)'
@@ -54,7 +66,7 @@ def process_failures(test, test_count, browser_type, duration):
5466 "FAILED!" ,
5567 bad_page_data ,
5668 bad_page_image ,
57- test .driver . current_url ,
69+ test ._last_page_url ,
5870 test .browser ,
5971 get_timestamp ()[:- 3 ],
6072 duration ,
@@ -222,10 +234,25 @@ def build_report(report_log_path, page_results_list,
222234 "\n * Files saved for this report are located at:\n " + report_log_path )
223235 print ("" )
224236 if show_report :
237+ browser = None
238+ profile = webdriver .FirefoxProfile ()
239+ profile .set_preference ("app.update.auto" , False )
240+ profile .set_preference ("app.update.enabled" , False )
241+ profile .set_preference ("browser.privatebrowsing.autostart" , True )
225242 if browser_type == 'firefox' :
226- browser = webdriver .Firefox ()
243+ if LOCAL_GECKODRIVER and os .path .exists (LOCAL_GECKODRIVER ):
244+ browser = webdriver .Firefox (
245+ firefox_profile = profile , executable_path = LOCAL_GECKODRIVER )
246+ else :
247+ browser = webdriver .Firefox (firefox_profile = profile )
227248 else :
228- browser = webdriver .Chrome ()
249+ chrome_options = webdriver .ChromeOptions ()
250+ chrome_options .add_argument ("--disable-infobars" )
251+ if LOCAL_CHROMEDRIVER and os .path .exists (LOCAL_CHROMEDRIVER ):
252+ browser = webdriver .Chrome (
253+ executable_path = LOCAL_CHROMEDRIVER , options = chrome_options )
254+ else :
255+ browser = webdriver .Chrome (options = chrome_options )
229256 browser .get ("file://%s" % archived_results_file )
230257 print ("\n *** Close the html report window to continue. ***" )
231258 while len (browser .window_handles ):
0 commit comments