Skip to content

Commit 35e4f99

Browse files
authored
Merge pull request #479 from seleniumbase/ready-for-edge-chromium
Ready for Edge/EdgeDriver (Chromium)
2 parents dce1b5e + 64628e4 commit 35e4f99

File tree

9 files changed

+73
-22
lines changed

9 files changed

+73
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_sb29.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
1+
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_sb30.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
22

33
[<img src="https://img.shields.io/github/release/seleniumbase/SeleniumBase.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/releases) [<img src="https://img.shields.io/pypi/v/seleniumbase.svg" alt=" " />](https://pypi.python.org/pypi/seleniumbase) [<img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" alt=" " />](https://gitter.im/seleniumbase/SeleniumBase) [<img src="https://img.shields.io/travis/seleniumbase/SeleniumBase/master.svg?logo=travis" alt=" " />](https://travis-ci.org/seleniumbase/SeleniumBase) [<img src="https://dev.azure.com/seleniumbase/seleniumbase/_apis/build/status/seleniumbase.SeleniumBase?branchName=master" alt=" " />](https://dev.azure.com/seleniumbase/seleniumbase/_build) [<img src="https://github.com/seleniumbase/SeleniumBase/workflows/CI%20build/badge.svg">](https://github.com/seleniumbase/SeleniumBase/actions) [<img src="https://img.shields.io/badge/license-MIT-22BBCC.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/blob/master/LICENSE) [<img src="https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/stargazers)
44

examples/ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ python gui_test_runner.py
109109

110110
--------
111111

112-
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_sb23.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
112+
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_sb30.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)

examples/edge_test.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
This test is only for Microsoft Edge (Chromium)!
3+
"""
4+
from seleniumbase import BaseCase
5+
6+
7+
class EdgeTestClass(BaseCase):
8+
9+
def test_edge(self):
10+
if self.browser != "edge":
11+
print("\n This test is only for Microsoft Edge (Chromium)!")
12+
print(" (Run with: '--browser=edge')")
13+
self.skipTest("This test is only for Microsoft Edge (Chromium)! ")
14+
self.open("edge://settings/help")
15+
self.assert_element('img[alt="Edge logo"] + span')
16+
self.highlight('div[role="main"] div div div + div')
17+
self.highlight('div[role="main"] div div div + div > div')
18+
self.highlight('img[alt="Edge logo"]')
19+
self.highlight('img[alt="Edge logo"] + span')
20+
self.highlight('div[role="main"] div div div + div > div + div')
21+
self.highlight('div[role="main"] div div div + div > div + div + div')

help_docs/customizing_test_runs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_m.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
1+
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_sb30.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
22

33
## <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Customizing test runs
44

help_docs/features_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_m.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
1+
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_sb30.png" title="SeleniumBase" height="48">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
22

33
<a id="feature_list"></a>
44
## <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> **Features:**

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ setuptools>=44.0.0;python_version<"3"
33
setuptools>=45.0.0;python_version>="3"
44
setuptools-scm>=3.3.3
55
wheel>=0.33.6
6-
six==1.13.0
6+
six==1.14.0
77
nose==1.3.7
88
ipdb==0.12.3
99
idna==2.8

seleniumbase/console_scripts/sb_install.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
LOCAL_PATH = "/usr/local/bin/" # On Mac and Linux systems
4040
DEFAULT_CHROMEDRIVER_VERSION = "2.44"
4141
DEFAULT_GECKODRIVER_VERSION = "v0.26.0"
42-
DEFAULT_EDGEDRIVER_VERSION = "77.0.235.20"
42+
DEFAULT_EDGEDRIVER_VERSION = "79.0.309.65"
4343
DEFAULT_OPERADRIVER_VERSION = "v.75.0.3770.100"
4444

4545

@@ -82,7 +82,9 @@ def make_executable(file_path):
8282
def main(override=None):
8383
if override == "chromedriver":
8484
sys.argv = ["seleniumbase", "install", "chromedriver"]
85-
if override == "geckodriver":
85+
elif override == "edgedriver":
86+
sys.argv = ["seleniumbase", "install", "edgedriver"]
87+
elif override == "geckodriver":
8688
sys.argv = ["seleniumbase", "install", "geckodriver"]
8789

8890
num_args = len(sys.argv)

seleniumbase/core/browser_launcher.py

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ def is_chromedriver_on_path():
8282
return False
8383

8484

85+
def is_edgedriver_on_path():
86+
paths = os.environ["PATH"].split(os.pathsep)
87+
for path in paths:
88+
if os.path.exists(path + '/' + "msedgedriver"):
89+
return True
90+
return False
91+
92+
8593
def is_geckodriver_on_path():
8694
paths = os.environ["PATH"].split(os.pathsep)
8795
for path in paths:
@@ -95,7 +103,8 @@ def _add_chrome_proxy_extension(
95103
""" Implementation of https://stackoverflow.com/a/35293284 for
96104
https://stackoverflow.com/questions/12848327/
97105
(Run Selenium on a proxy server that requires authentication.) """
98-
if not ("-n" in sys.argv or "".join(sys.argv) == "-c"):
106+
arg_join = " ".join(sys.argv)
107+
if not ("-n" in sys.argv or "-n=" in arg_join or arg_join == "-c"):
99108
# Single-threaded
100109
proxy_helper.create_proxy_zip(proxy_string, proxy_user, proxy_pass)
101110
else:
@@ -229,7 +238,7 @@ def _create_firefox_profile(
229238
profile.set_preference("app.update.enabled", False)
230239
profile.set_preference("app.update.silent", True)
231240
profile.set_preference("browser.privatebrowsing.autostart", True)
232-
profile.set_preference("devtools.errorconsole.enabled", True)
241+
profile.set_preference("devtools.errorconsole.enabled", False)
233242
profile.set_preference("extensions.allowPrivateBrowsingByDefault", True)
234243
profile.set_preference("extensions.PrivateBrowsing.notification", False)
235244
profile.set_preference("extensions.systemAddon.update.enabled", False)
@@ -410,7 +419,7 @@ def get_remote_driver(
410419
for key in desired_caps.keys():
411420
firefox_capabilities[key] = desired_caps[key]
412421
capabilities = firefox_capabilities
413-
address = "http://%s:%s/wd/hub" % (servername, port)
422+
warnings.simplefilter("ignore", category=DeprecationWarning)
414423
return webdriver.Remote(
415424
command_executor=address,
416425
desired_capabilities=capabilities,
@@ -529,7 +538,8 @@ def get_local_driver(
529538
logging.debug("\nWarning: Could not make geckodriver"
530539
" executable: %s" % e)
531540
elif not is_geckodriver_on_path():
532-
if not ("-n" in sys.argv or "".join(sys.argv) == "-c"):
541+
args = " ".join(sys.argv)
542+
if not ("-n" in sys.argv or "-n=" in args or args == "-c"):
533543
# (Not multithreaded)
534544
from seleniumbase.console_scripts import sb_install
535545
sys_args = sys.argv # Save a copy of current sys args
@@ -583,23 +593,40 @@ def get_local_driver(
583593
" executable: %s" % e)
584594
return webdriver.Ie(capabilities=ie_capabilities)
585595
elif browser_name == constants.Browser.EDGE:
586-
if LOCAL_EDGEDRIVER and os.path.exists(LOCAL_EDGEDRIVER):
587-
try:
588-
make_driver_executable_if_not(LOCAL_EDGEDRIVER)
589-
except Exception as e:
590-
logging.debug("\nWarning: Could not make edgedriver"
591-
" executable: %s" % e)
592-
# The new Microsoft Edge browser is based on Chromium
596+
try:
593597
chrome_options = _set_chrome_options(
594598
downloads_path, headless,
595599
proxy_string, proxy_auth, proxy_user, proxy_pass, user_agent,
596600
disable_csp, enable_sync, incognito, user_data_dir,
597601
extension_zip, extension_dir, servername, mobile_emulator,
598602
device_width, device_height, device_pixel_ratio)
603+
if LOCAL_EDGEDRIVER and os.path.exists(LOCAL_EDGEDRIVER):
604+
try:
605+
make_driver_executable_if_not(LOCAL_EDGEDRIVER)
606+
except Exception as e:
607+
logging.debug("\nWarning: Could not make edgedriver"
608+
" executable: %s" % e)
609+
elif not is_edgedriver_on_path():
610+
args = " ".join(sys.argv)
611+
if not ("-n" in sys.argv or "-n=" in args or args == "-c"):
612+
# (Not multithreaded)
613+
from seleniumbase.console_scripts import sb_install
614+
sys_args = sys.argv # Save a copy of current sys args
615+
print("\nWarning: chromedriver not found. Installing now:")
616+
sb_install.main(override="edgedriver")
617+
sys.argv = sys_args # Put back the original sys args
599618
return webdriver.Chrome(executable_path=LOCAL_EDGEDRIVER,
600619
options=chrome_options)
601-
else:
602-
return webdriver.Edge()
620+
except Exception as e:
621+
if headless:
622+
raise Exception(e)
623+
if LOCAL_EDGEDRIVER and os.path.exists(LOCAL_EDGEDRIVER):
624+
try:
625+
make_driver_executable_if_not(LOCAL_EDGEDRIVER)
626+
except Exception as e:
627+
logging.debug("\nWarning: Could not make edgedriver"
628+
" executable: %s" % e)
629+
return webdriver.Chrome(executable_path=LOCAL_EDGEDRIVER)
603630
elif browser_name == constants.Browser.SAFARI:
604631
arg_join = " ".join(sys.argv)
605632
if ("-n" in sys.argv) or ("-n=" in arg_join) or (arg_join == "-c"):
@@ -634,7 +661,8 @@ def get_local_driver(
634661
logging.debug("\nWarning: Could not make chromedriver"
635662
" executable: %s" % e)
636663
elif not is_chromedriver_on_path():
637-
if not ("-n" in sys.argv or "".join(sys.argv) == "-c"):
664+
args = " ".join(sys.argv)
665+
if not ("-n" in sys.argv or "-n=" in args or args == "-c"):
638666
# (Not multithreaded)
639667
from seleniumbase.console_scripts import sb_install
640668
sys_args = sys.argv # Save a copy of current sys args

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
setup(
4747
name='seleniumbase',
48-
version='1.34.19',
48+
version='1.34.20',
4949
description='Fast, Easy, and Reliable Browser Automation & Testing.',
5050
long_description=long_description,
5151
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)