Skip to content

Commit f01a92b

Browse files
committed
Bring back support for Microsoft Edge
1 parent 8b3a69f commit f01a92b

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ chardet==3.0.4
1414
urllib3==1.25.10
1515
requests==2.24.0
1616
selenium==3.141.0
17+
msedge-selenium-tools==3.141.2
1718
pluggy==0.13.1
1819
attrs>=19.3.0
1920
py==1.8.1;python_version<"3.5"

seleniumbase/console_scripts/sb_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
LOCAL_PATH = "/usr/local/bin/" # On Mac and Linux systems
4242
DEFAULT_CHROMEDRIVER_VERSION = "2.44"
4343
DEFAULT_GECKODRIVER_VERSION = "v0.26.0"
44-
DEFAULT_EDGEDRIVER_VERSION = "79.0.309.65"
44+
DEFAULT_EDGEDRIVER_VERSION = "84.0.522.52"
4545
DEFAULT_OPERADRIVER_VERSION = "v.81.0.4044.113"
4646

4747

seleniumbase/core/browser_launcher.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -699,16 +699,47 @@ def get_local_driver(
699699
sys.argv = sys_args # Put back the original sys args
700700
return webdriver.Chrome(executable_path=LOCAL_EDGEDRIVER,
701701
options=chrome_options)
702-
except Exception as e:
703-
if headless:
704-
raise Exception(e)
702+
except Exception:
703+
from msedge.selenium_tools import Edge, EdgeOptions
705704
if LOCAL_EDGEDRIVER and os.path.exists(LOCAL_EDGEDRIVER):
706705
try:
707706
make_driver_executable_if_not(LOCAL_EDGEDRIVER)
708707
except Exception as e:
709708
logging.debug("\nWarning: Could not make edgedriver"
710709
" executable: %s" % e)
711-
return webdriver.Chrome(executable_path=LOCAL_EDGEDRIVER)
710+
edge_options = EdgeOptions()
711+
edge_options.use_chromium = True
712+
edge_options.add_experimental_option(
713+
"useAutomationExtension", False)
714+
edge_options.add_experimental_option(
715+
"excludeSwitches", ["enable-automation", "enable-logging"])
716+
if guest_mode:
717+
edge_options.add_argument("--guest")
718+
if headless:
719+
edge_options.add_argument("--headless")
720+
if mobile_emulator:
721+
emulator_settings = {}
722+
device_metrics = {}
723+
if type(device_width) is int and (
724+
type(device_height) is int and (
725+
type(device_pixel_ratio) is int)):
726+
device_metrics["width"] = device_width
727+
device_metrics["height"] = device_height
728+
device_metrics["pixelRatio"] = device_pixel_ratio
729+
else:
730+
device_metrics["width"] = 411
731+
device_metrics["height"] = 731
732+
device_metrics["pixelRatio"] = 3
733+
emulator_settings["deviceMetrics"] = device_metrics
734+
if user_agent:
735+
emulator_settings["userAgent"] = user_agent
736+
edge_options.add_experimental_option(
737+
"mobileEmulation", emulator_settings)
738+
edge_options.add_argument("--enable-sync")
739+
capabilities = edge_options.to_capabilities()
740+
capabilities["platform"] = ''
741+
return Edge(
742+
executable_path=LOCAL_EDGEDRIVER, capabilities=capabilities)
712743
elif browser_name == constants.Browser.SAFARI:
713744
arg_join = " ".join(sys.argv)
714745
if ("-n" in sys.argv) or ("-n=" in arg_join) or (arg_join == "-c"):

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
'urllib3==1.25.10', # Must stay in sync with "requests"
107107
'requests==2.24.0',
108108
'selenium==3.141.0',
109+
'msedge-selenium-tools==3.141.2',
109110
'pluggy==0.13.1',
110111
'attrs>=19.3.0',
111112
'py==1.8.1;python_version<"3.5"',

0 commit comments

Comments
 (0)