Skip to content

Commit

Permalink
Fix IE Compatibility Mode with Edge
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmintz committed Mar 14, 2024
1 parent f18213e commit 1bcda8f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
43 changes: 24 additions & 19 deletions seleniumbase/console_scripts/sb_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,7 @@ def main(override=None, intel_for_uc=None, force_uc=None):
p_version = c3 + use_version + cr
log_d("\n*** %s = %s" % (msg, p_version))
elif name == "iedriver":
major_version = "3.14"
full_version = "3.14.0"
full_version = "4.14.0"
use_version = full_version
if IS_WINDOWS and "64" in ARCH:
file_name = "IEDriverServer_x64_%s.zip" % full_version
Expand All @@ -723,8 +722,9 @@ def main(override=None, intel_for_uc=None, force_uc=None):
"Windows-based systems!"
)
download_url = (
"https://selenium-release.storage.googleapis.com/"
"%s/%s" % (major_version, file_name)
"https://github.com/SeleniumHQ/selenium/"
"releases/download/selenium-"
"%s/%s" % (full_version, file_name)
)
headless_ie_version = "v1.4"
headless_ie_file_name = "headless-selenium-for-win-v1-4.zip"
Expand Down Expand Up @@ -949,7 +949,11 @@ def main(override=None, intel_for_uc=None, force_uc=None):
make_executable(path_file)
log_d("Also copied to: %s%s%s" % (c3, path_file, cr))
log_d("")
elif name == "edgedriver" or name == "msedgedriver":
elif (
name == "edgedriver"
or name == "msedgedriver"
or name == "iedriver"
):
if IS_MAC or IS_LINUX:
# Mac / Linux
expected_contents = [
Expand All @@ -969,6 +973,8 @@ def main(override=None, intel_for_uc=None, force_uc=None):
"Driver_Notes/LICENSE",
"msedgedriver.exe",
]
if name == "iedriver":
expected_contents = ["IEDriverServer.exe"]
if len(contents) > 5:
raise Exception("Unexpected content in EdgeDriver Zip file!")
for content in contents:
Expand All @@ -984,21 +990,20 @@ def main(override=None, intel_for_uc=None, force_uc=None):
# Remove existing version if exists
str_name = str(f_name)
new_file = os.path.join(downloads_folder, str_name)
if IS_MAC or IS_LINUX:
# Mac / Linux
if str_name == "msedgedriver":
driver_file = str_name
driver_path = new_file
if os.path.exists(new_file):
os.remove(new_file)
else:
# Windows
if str_name == "msedgedriver.exe":
driver_file = str_name
driver_path = new_file
if os.path.exists(new_file):
os.remove(new_file)
if (
((IS_MAC or IS_LINUX) and str_name == "msedgedriver")
or (
str_name == "msedgedriver.exe"
or str_name == "IEDriverServer.exe"
)
):
driver_file = str_name
driver_path = new_file
if os.path.exists(new_file):
os.remove(new_file)
if not driver_file or not driver_path:
if str_name == "IEDriverServer.exe":
raise Exception("IEDriverServer missing from Zip file!")
raise Exception("msedgedriver missing from Zip file!")
log_d("Extracting %s from %s ..." % (contents, file_name))
zip_ref.extractall(downloads_folder)
Expand Down
12 changes: 7 additions & 5 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2304,14 +2304,14 @@ def get_local_driver(
"IE Browser is for Windows-based systems only!"
)
from selenium.webdriver.ie.options import Options
from selenium.webdriver.ie.service import Service
ie_options = Options()
ie_options.ignore_protected_mode_settings = True
ie_options.ignore_zoom_level = True
ie_options.require_window_focus = False
ie_options.native_events = True
ie_options.full_page_screenshot = True
ie_options.persistent_hover = True
ie_capabilities = ie_options.to_capabilities()
if LOCAL_IEDRIVER and os.path.exists(LOCAL_IEDRIVER):
try:
make_driver_executable_if_not(LOCAL_IEDRIVER)
Expand Down Expand Up @@ -2345,16 +2345,18 @@ def get_local_driver(
log_d("\nWarning: HeadlessIEDriver not found. Getting it now:")
sb_install.main(override="iedriver")
sys.argv = sys_args # Put back the original sys args
d_b_c = "--disable-build-check"
if not headless:
warnings.simplefilter("ignore", category=DeprecationWarning)
driver = webdriver.Ie(capabilities=ie_capabilities)
service = Service(service_args=[d_b_c])
driver = webdriver.Ie(service=service, options=ie_options)
return extend_driver(driver)
else:
warnings.simplefilter("ignore", category=DeprecationWarning)
driver = webdriver.Ie(
executable_path=LOCAL_HEADLESS_IEDRIVER,
capabilities=ie_capabilities,
service = Service(
executable_path=LOCAL_IEDRIVER, service_args=[d_b_c],
)
driver = webdriver.Ie(service=service, options=ie_options)
return extend_driver(driver)
elif browser_name == constants.Browser.EDGE:
prefs = {
Expand Down

0 comments on commit 1bcda8f

Please sign in to comment.