Skip to content

Commit 420b6cc

Browse files
authored
Merge pull request #647 from seleniumbase/make-edge-work-again
Bring back support for Microsoft Edge
2 parents 8b3a69f + fa4a108 commit 420b6cc

File tree

7 files changed

+54
-16
lines changed

7 files changed

+54
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ Here are some useful command-line options that come with ``pytest``:
292292
-s # See print statements. (Should be on by default with pytest.ini present.)
293293
--junit-xml=report.xml # Creates a junit-xml report after tests finish.
294294
--pdb # If a test fails, pause run and enter debug mode. (Don't use with CI!)
295-
-m=MARKER # Only run tests that are marked with the specified pytest marker.
295+
-m=MARKER # Run tests with the specified pytest marker.
296296
```
297297

298298
SeleniumBase provides additional ``pytest`` command-line options for tests:

help_docs/customizing_test_runs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Here are some useful command-line options that come with ``pytest``:
8787
-s # See print statements. (Should be on by default with pytest.ini present.)
8888
--junit-xml=report.xml # Creates a junit-xml report after tests finish.
8989
--pdb # If a test fails, pause run and enter debug mode. (Don't use with CI!)
90-
-m=MARKER # Only run tests that are marked with the specified pytest marker.
90+
-m=MARKER # Run tests with the specified pytest marker.
9191
```
9292

9393
SeleniumBase provides additional ``pytest`` command-line options for tests:

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/run.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,28 +456,28 @@ def show_options():
456456
print('--slow (Slow down the automation. Faster than using Demo Mode.)')
457457
print('--reuse-session / --rs (Reuse the browser session between tests.)')
458458
print('--crumbs (Delete all cookies between tests reusing a session.)')
459-
print("--guest (Enable Chrome's Guest mode.)")
459+
print('--maximize (Start tests with the web browser window maximized.)')
460460
print("--incognito (Enable Chrome's Incognito mode.)")
461-
print('-m MARKER (Only run tests with the specified pytest marker.)')
461+
print("--guest (Enable Chrome's Guest mode.)")
462+
print('-m MARKER (Run tests with the specified pytest marker.)')
462463
print('-n NUM (Multithread the tests using that many threads.)')
463464
print('-v (Verbose mode. Print the full name of each test run.)')
465+
print('--check-js (Check for JavaScript errors after page loads.)')
466+
print('--html=report.html (Create a detailed pytest-html report.)')
464467
print("--agent=STRING (Modify the web browser's User-Agent string.)")
465468
print('--mobile (Use the mobile device emulator while running tests.)')
466469
print('--metrics=STRING (Set mobile "CSSWidth,CSSHeight,PixelRatio".)')
467-
print('--maximize (Start tests with the web browser window maximized.)')
468470
print('--ad-block (Block some types of display ads after page loads.)')
469-
print('--check-js (Check for JavaScript errors after page loads.)')
470471
print('--pdb (Enter Debug Mode if a test fails. h: Help. c: Continue.')
471472
print(' interact: Interactive Mode. CTRL-D: Exit Interactive Mode.)')
472-
print('--html=report.html (Create a detailed pytest-html report.)')
473473
print('--archive-logs (Archive old log files instead of deleting them.)')
474474
print('--disable-csp (Disable the Content Security Policy of websites.)')
475+
print('--save-screenshot (Save a screenshot at the end of each test.)')
475476
print('--proxy=SERVER:PORT (Set a proxy server:port combo for tests.)')
476477
print("--settings-file=FILE (Override default SeleniumBase settings.)")
477478
print('--env=ENV (Set the test env. Access with "self.env" in tests.)')
478479
print('--data=DATA (Extra test data. Access with "self.data" in tests.)')
479480
print('--collect-only -q (Show discovered tests without running them.)')
480-
print('--save-screenshot (Save a screenshot at the end of each test.)')
481481
print('-x (Stop running tests after the first failure is reached.)')
482482
print("")
483483
line = 'For the full list of ' + c1 + 'command-line options' + cr

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: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ def _set_chrome_options(
234234
chrome_options = _add_chrome_proxy_extension(
235235
chrome_options, proxy_string, proxy_user, proxy_pass)
236236
chrome_options.add_argument('--proxy-server=%s' % proxy_string)
237-
else:
238-
chrome_options.add_argument("--no-proxy-server")
239237
if headless:
240238
if not proxy_auth:
241239
# Headless Chrome doesn't support extensions, which are
@@ -699,16 +697,54 @@ def get_local_driver(
699697
sys.argv = sys_args # Put back the original sys args
700698
return webdriver.Chrome(executable_path=LOCAL_EDGEDRIVER,
701699
options=chrome_options)
702-
except Exception as e:
703-
if headless:
704-
raise Exception(e)
700+
except Exception:
701+
from msedge.selenium_tools import Edge, EdgeOptions
705702
if LOCAL_EDGEDRIVER and os.path.exists(LOCAL_EDGEDRIVER):
706703
try:
707704
make_driver_executable_if_not(LOCAL_EDGEDRIVER)
708705
except Exception as e:
709706
logging.debug("\nWarning: Could not make edgedriver"
710707
" executable: %s" % e)
711-
return webdriver.Chrome(executable_path=LOCAL_EDGEDRIVER)
708+
edge_options = EdgeOptions()
709+
edge_options.use_chromium = True
710+
edge_options.add_experimental_option(
711+
"useAutomationExtension", False)
712+
edge_options.add_experimental_option(
713+
"excludeSwitches", ["enable-automation", "enable-logging"])
714+
if guest_mode:
715+
edge_options.add_argument("--guest")
716+
if headless:
717+
edge_options.add_argument("--headless")
718+
if mobile_emulator:
719+
emulator_settings = {}
720+
device_metrics = {}
721+
if type(device_width) is int and (
722+
type(device_height) is int and (
723+
type(device_pixel_ratio) is int)):
724+
device_metrics["width"] = device_width
725+
device_metrics["height"] = device_height
726+
device_metrics["pixelRatio"] = device_pixel_ratio
727+
else:
728+
device_metrics["width"] = 411
729+
device_metrics["height"] = 731
730+
device_metrics["pixelRatio"] = 3
731+
emulator_settings["deviceMetrics"] = device_metrics
732+
if user_agent:
733+
emulator_settings["userAgent"] = user_agent
734+
edge_options.add_experimental_option(
735+
"mobileEmulation", emulator_settings)
736+
edge_options.add_argument("--enable-sync")
737+
if proxy_string:
738+
if proxy_auth:
739+
edge_options = _add_chrome_proxy_extension(
740+
edge_options, proxy_string, proxy_user, proxy_pass)
741+
edge_options.add_argument('--proxy-server=%s' % proxy_string)
742+
if user_agent:
743+
edge_options.add_argument("--user-agent=%s" % user_agent)
744+
capabilities = edge_options.to_capabilities()
745+
capabilities["platform"] = ''
746+
return Edge(
747+
executable_path=LOCAL_EDGEDRIVER, capabilities=capabilities)
712748
elif browser_name == constants.Browser.SAFARI:
713749
arg_join = " ".join(sys.argv)
714750
if ("-n" in sys.argv) or ("-n=" in arg_join) or (arg_join == "-c"):

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
setup(
5656
name='seleniumbase',
57-
version='1.46.0',
57+
version='1.46.1',
5858
description='Web Automation and Testing Framework - seleniumbase.io',
5959
long_description=long_description,
6060
long_description_content_type='text/markdown',
@@ -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)