Skip to content

Commit b853569

Browse files
committed
Update logging around making web drivers executable
1 parent 3c8665b commit b853569

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import os
23
import random
34
import re
@@ -519,8 +520,8 @@ def get_local_driver(
519520
try:
520521
make_driver_executable_if_not(LOCAL_GECKODRIVER)
521522
except Exception as e:
522-
print("\nWarning: Could not make geckodriver"
523-
" executable: %s" % e)
523+
logging.debug("\nWarning: Could not make geckodriver"
524+
" executable: %s" % e)
524525
elif not is_geckodriver_on_path():
525526
if not "".join(sys.argv) == "-c": # Skip if multithreaded
526527
from seleniumbase.console_scripts import sb_install
@@ -563,11 +564,19 @@ def get_local_driver(
563564
ie_options.persistent_hover = True
564565
ie_capabilities = ie_options.to_capabilities()
565566
if LOCAL_IEDRIVER and os.path.exists(LOCAL_IEDRIVER):
566-
make_driver_executable_if_not(LOCAL_IEDRIVER)
567+
try:
568+
make_driver_executable_if_not(LOCAL_IEDRIVER)
569+
except Exception as e:
570+
logging.debug("\nWarning: Could not make iedriver"
571+
" executable: %s" % e)
567572
return webdriver.Ie(capabilities=ie_capabilities)
568573
elif browser_name == constants.Browser.EDGE:
569574
if LOCAL_EDGEDRIVER and os.path.exists(LOCAL_EDGEDRIVER):
570-
make_driver_executable_if_not(LOCAL_EDGEDRIVER)
575+
try:
576+
make_driver_executable_if_not(LOCAL_EDGEDRIVER)
577+
except Exception as e:
578+
logging.debug("\nWarning: Could not make edgedriver"
579+
" executable: %s" % e)
571580
# The new Microsoft Edge browser is based on Chromium
572581
chrome_options = _set_chrome_options(
573582
downloads_path, headless,
@@ -585,7 +594,11 @@ def get_local_driver(
585594
return webdriver.Safari()
586595
elif browser_name == constants.Browser.OPERA:
587596
if LOCAL_OPERADRIVER and os.path.exists(LOCAL_OPERADRIVER):
588-
make_driver_executable_if_not(LOCAL_OPERADRIVER)
597+
try:
598+
make_driver_executable_if_not(LOCAL_OPERADRIVER)
599+
except Exception as e:
600+
logging.debug("\nWarning: Could not make operadriver"
601+
" executable: %s" % e)
589602
return webdriver.Opera()
590603
elif browser_name == constants.Browser.PHANTOM_JS:
591604
with warnings.catch_warnings():
@@ -601,7 +614,11 @@ def get_local_driver(
601614
extension_zip, extension_dir, servername, mobile_emulator,
602615
device_width, device_height, device_pixel_ratio)
603616
if LOCAL_CHROMEDRIVER and os.path.exists(LOCAL_CHROMEDRIVER):
604-
make_driver_executable_if_not(LOCAL_CHROMEDRIVER)
617+
try:
618+
make_driver_executable_if_not(LOCAL_CHROMEDRIVER)
619+
except Exception as e:
620+
logging.debug("\nWarning: Could not make chromedriver"
621+
" executable: %s" % e)
605622
elif not is_chromedriver_on_path():
606623
if not "".join(sys.argv) == "-c": # Skip if multithreaded
607624
from seleniumbase.console_scripts import sb_install
@@ -614,7 +631,11 @@ def get_local_driver(
614631
if headless:
615632
raise Exception(e)
616633
if LOCAL_CHROMEDRIVER and os.path.exists(LOCAL_CHROMEDRIVER):
617-
make_driver_executable_if_not(LOCAL_CHROMEDRIVER)
634+
try:
635+
make_driver_executable_if_not(LOCAL_CHROMEDRIVER)
636+
except Exception as e:
637+
logging.debug("\nWarning: Could not make chromedriver"
638+
" executable: %s" % e)
618639
return webdriver.Chrome()
619640
else:
620641
raise Exception(

0 commit comments

Comments
 (0)