6
6
from seleniumbase .config import settings
7
7
from seleniumbase .core .style_sheet import style
8
8
from seleniumbase .fixtures import page_actions
9
+ from seleniumbase import drivers
9
10
10
11
LATEST_REPORT_DIR = settings .LATEST_REPORT_DIR
11
12
ARCHIVE_DIR = settings .REPORT_ARCHIVE_DIR
12
13
HTML_REPORT = settings .HTML_REPORT
13
14
RESULTS_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'
14
25
15
26
16
27
def get_timestamp ():
@@ -35,8 +46,9 @@ def process_successes(test, test_count, duration):
35
46
def process_failures (test , test_count , browser_type , duration ):
36
47
bad_page_image = "failure_%s.png" % test_count
37
48
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 )
40
52
page_actions .save_test_failure_data (
41
53
test .driver , bad_page_data , browser_type , folder = LATEST_REPORT_DIR )
42
54
exc_info = '(Unknown Failure)'
@@ -54,7 +66,7 @@ def process_failures(test, test_count, browser_type, duration):
54
66
"FAILED!" ,
55
67
bad_page_data ,
56
68
bad_page_image ,
57
- test .driver . current_url ,
69
+ test ._last_page_url ,
58
70
test .browser ,
59
71
get_timestamp ()[:- 3 ],
60
72
duration ,
@@ -222,10 +234,25 @@ def build_report(report_log_path, page_results_list,
222
234
"\n * Files saved for this report are located at:\n " + report_log_path )
223
235
print ("" )
224
236
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 )
225
242
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 )
227
248
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 )
229
256
browser .get ("file://%s" % archived_results_file )
230
257
print ("\n *** Close the html report window to continue. ***" )
231
258
while len (browser .window_handles ):
0 commit comments