Skip to content

Commit ec741c2

Browse files
authored
Merge pull request #371 from seleniumbase/many-updates
Many Updates
2 parents 3fbf5b3 + d364da5 commit ec741c2

File tree

12 files changed

+130
-52
lines changed

12 files changed

+130
-52
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ test-results.xml
5454
# Web Drivers
5555
chromedriver
5656
geckodriver
57+
msedgedriver
5758
operadriver
5859
MicrosoftWebDriver.exe
5960
IEDriverServer.exe
6061
chromedriver.exe
6162
geckodriver.exe
63+
msedgedriver.exe
6264
operadriver.exe
6365

6466
# Logs

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ install:
2020
- "python setup.py develop"
2121
- "sudo rm -f /etc/boto.cfg"
2222
before_script:
23-
- "flake8 seleniumbase/*.py && flake8 seleniumbase/*/*.py && flake8 seleniumbase/*/*/*.py && flake8 seleniumbase/*/*/*/*.py"
23+
- "flake8 --exclude=temp"
2424
# - "wget https://chromedriver.storage.googleapis.com/2.44/chromedriver_linux64.zip && unzip chromedriver_linux64.zip && sudo cp chromedriver /usr/local/bin/ && sudo chmod +x /usr/local/bin/chromedriver"
2525
# - "wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz -O /tmp/geckodriver.tar.gz && tar -C /opt -xzf /tmp/geckodriver.tar.gz && sudo chmod 755 /opt/geckodriver && sudo ln -fs /opt/geckodriver /usr/bin/geckodriver && sudo ln -fs /opt/geckodriver /usr/local/bin/geckodriver"
2626
# - "wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 && tar -xvf ./phantomjs-2.1.1-linux-x86_64.tar.bz2 && export PATH=$PWD/phantomjs-2.1.1-linux-x86_64/bin:$PATH"

seleniumbase/console_scripts/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def show_install_usage():
5959
print(" (Drivers: chromedriver, geckodriver, edgedriver")
6060
print(" iedriver, operadriver)")
6161
print(" Options:")
62-
print(" VERSION - Specify the version (For Chromedriver ONLY).")
62+
print(" VERSION - Specify version (Chromedriver / EdgeDr ONLY).")
6363
print(" (Default Chromedriver version = 2.44)")
6464
print(' Use "latest" to get the latest Chromedriver.')
6565
print(" Example:")

seleniumbase/console_scripts/sb_install.py

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
seleniumbase install {chromedriver|geckodriver|edgedriver|
66
iedriver|operadriver} [OPTIONS]
77
Options:
8-
VERSION - Specify the version (For Chromedriver ONLY)
8+
VERSION - Specify version (Chromedriver / Edgedriver ONLY)
99
(Default Chromedriver version = 2.44)
1010
Use "latest" to get the latest Chromedriver.
1111
Example:
@@ -34,6 +34,7 @@
3434
urllib3.disable_warnings()
3535
DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
3636
DEFAULT_CHROMEDRIVER_VERSION = "2.44"
37+
DEFAULT_EDGEDRIVER_VERSION = "78.0.268.0"
3738

3839

3940
def invalid_run_command():
@@ -43,7 +44,7 @@ def invalid_run_command():
4344
exp += " (Drivers: chromedriver, geckodriver, edgedriver,\n"
4445
exp += " iedriver, operadriver)\n"
4546
exp += " Options:\n"
46-
exp += " VERSION - Specify the version (For Chromedriver ONLY)."
47+
exp += " VERSION - Specify version (Chromedriver / EdgeDr ONLY)."
4748
exp += " (Default Chromedriver version = 2.44)"
4849
exp += ' Use "latest" to get the latest Chromedriver.'
4950
exp += " Example:\n"
@@ -86,6 +87,9 @@ def main():
8687
expected_contents = None
8788
platform_code = None
8889
inner_folder = None
90+
use_version = ""
91+
new_file = ""
92+
f_name = ""
8993

9094
if name == "chromedriver":
9195
use_version = DEFAULT_CHROMEDRIVER_VERSION
@@ -140,17 +144,26 @@ def main():
140144
"%s/%s" % (use_version, file_name))
141145
elif name == "edgedriver" or name == "microsoftwebdriver":
142146
name = "edgedriver"
143-
version_code = "F/8/A/F8AF50AB-3C3A-4BC4-8773-DC27B32988DD"
144-
if "win32" in sys_plat or "win64" in sys_plat or "x64" in sys_plat:
145-
file_name = "MicrosoftWebDriver.exe"
147+
use_version = DEFAULT_EDGEDRIVER_VERSION
148+
if num_args == 4:
149+
use_version = sys.argv[3]
150+
if use_version.lower() == "latest":
151+
use_version = DEFAULT_EDGEDRIVER_VERSION
152+
if "win64" in sys_plat or "x64" in sys_plat:
153+
file_name = "edgedriver_win64.zip"
154+
elif "win32" in sys_plat or "x86" in sys_plat:
155+
file_name = "edgedriver_win32.zip"
156+
elif "darwin" in sys_plat:
157+
file_name = "edgedriver_mac64.zip"
146158
else:
147159
raise Exception("Sorry! Microsoft WebDriver / EdgeDriver is "
148-
"only for Windows-based operating systems!")
149-
download_url = ("https://download.microsoft.com/download/"
150-
"%s/%s" % (version_code, file_name))
160+
"only for Windows or Mac operating systems!")
161+
download_url = ("https://msedgedriver.azureedge.net/"
162+
"%s/%s" % (use_version, file_name))
151163
elif name == "iedriver":
152164
major_version = "3.14"
153165
full_version = "3.14.0"
166+
use_version = full_version
154167
if "win32" in sys_plat:
155168
file_name = "IEDriverServer_Win32_%s.zip" % full_version
156169
elif "win64" in sys_plat or "x64" in sys_plat:
@@ -234,10 +247,16 @@ def main():
234247
print('Unzip Complete!\n')
235248
for f_name in contents:
236249
new_file = downloads_folder + '/' + str(f_name)
237-
print("%s saved!\n" % new_file)
238-
print("Making %s executable ..." % new_file)
250+
print("The file [%s] was saved to:\n%s\n" % (f_name, new_file))
251+
print("Making [%s] executable ..." % f_name)
239252
make_executable(new_file)
240-
print("%s is now ready for use!" % new_file)
253+
print("[%s] is now ready for use!\n" % f_name)
254+
print('(If running on a Selenium Grid, copy [%s] to your '
255+
'System PATH.\n'
256+
' E.g. to the "/usr/local/bin/" folder on Linux '
257+
'systems.)\n' % name)
258+
print("Location of [%s %s]:\n%s" % (
259+
f_name, use_version, new_file))
241260
print("")
242261
elif name == "operadriver":
243262
if len(contents) != 3:
@@ -266,10 +285,13 @@ def main():
266285
inner_driver = downloads_folder + '/' + inner_folder + driver_file
267286
inner_sha = downloads_folder + '/' + inner_folder + "sha512_sum"
268287
shutil.copyfile(inner_driver, driver_path)
269-
print("%s saved!\n" % driver_path)
270-
print("Making %s executable ..." % driver_path)
288+
print("The file [%s] was saved to:\n%s\n" % (
289+
driver_file, driver_path))
290+
print("Making [%s] executable ..." % driver_file)
271291
make_executable(driver_path)
272-
print("%s is now ready for use!" % driver_path)
292+
print("[%s] is now ready for use!\n" % driver_file)
293+
print("Location of [%s %s]:\n%s" % (
294+
driver_file, use_version, driver_path))
273295
# clean up extra files
274296
if os.path.exists(inner_driver):
275297
os.remove(inner_driver)
@@ -301,10 +323,16 @@ def main():
301323
print('Unzip Complete!\n')
302324
for f_name in contents:
303325
new_file = downloads_folder + '/' + str(f_name)
304-
print("%s saved!\n" % new_file)
305-
print("Making %s executable ..." % new_file)
326+
print("The file [%s] was saved to:\n%s\n" % (f_name, new_file))
327+
print("Making [%s] executable ..." % f_name)
306328
make_executable(new_file)
307-
print("%s is now ready for use!" % new_file)
329+
print("[%s] is now ready for use!\n" % f_name)
330+
print('(If running on a Selenium Grid, copy [%s] to your '
331+
'System PATH.\n'
332+
' E.g. to the "/usr/local/bin/" folder on Linux '
333+
'systems.)\n' % name)
334+
print("Location of [%s %s]:\n%s" % (
335+
f_name, use_version, new_file))
308336
print("")
309337
elif len(contents) == 0:
310338
raise Exception("Tar file %s is empty!" % tar_file_path)
@@ -313,9 +341,10 @@ def main():
313341
else:
314342
# Not a .zip file or a .tar.gz file. Just a direct download.
315343
if "Driver" in file_name or "driver" in file_name:
316-
print("Making %s executable ..." % file_path)
344+
print("Making [%s] executable ..." % file_name)
317345
make_executable(file_path)
318-
print("%s is now ready for use!\n" % file_path)
346+
print("[%s] is now ready for use!\n" % file_name)
347+
print("Location of [%s]:\n%s\n" % (file_name, file_path))
319348

320349

321350
if __name__ == "__main__":

seleniumbase/core/browser_launcher.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434
if "darwin" in PLATFORM or "linux" in PLATFORM:
3535
LOCAL_CHROMEDRIVER = DRIVER_DIR + '/chromedriver'
3636
LOCAL_GECKODRIVER = DRIVER_DIR + '/geckodriver'
37+
LOCAL_EDGEDRIVER = DRIVER_DIR + '/msedgedriver'
3738
LOCAL_OPERADRIVER = DRIVER_DIR + '/operadriver'
3839
elif "win32" in PLATFORM or "win64" in PLATFORM or "x64" in PLATFORM:
3940
IS_WINDOWS = True
40-
LOCAL_EDGEDRIVER = DRIVER_DIR + '/MicrosoftWebDriver.exe'
41+
LOCAL_EDGEDRIVER = DRIVER_DIR + '/msedgedriver.exe'
4142
LOCAL_IEDRIVER = DRIVER_DIR + '/IEDriverServer.exe'
4243
LOCAL_CHROMEDRIVER = DRIVER_DIR + '/chromedriver.exe'
4344
LOCAL_GECKODRIVER = DRIVER_DIR + '/geckodriver.exe'
@@ -507,17 +508,24 @@ def get_local_driver(
507508
else:
508509
return webdriver.Ie(capabilities=ie_capabilities)
509510
elif browser_name == constants.Browser.EDGE:
510-
if not IS_WINDOWS:
511-
raise Exception(
512-
"Edge Browser is for Windows-based operating systems only!")
513-
edge_capabilities = DesiredCapabilities.EDGE.copy()
514511
if LOCAL_EDGEDRIVER and os.path.exists(LOCAL_EDGEDRIVER):
515512
make_driver_executable_if_not(LOCAL_EDGEDRIVER)
516-
return webdriver.Edge(
517-
capabilities=edge_capabilities,
518-
executable_path=LOCAL_EDGEDRIVER)
513+
try:
514+
# The new Microsoft Edge browser is based on Chrome
515+
chrome_options = _set_chrome_options(
516+
downloads_path, headless,
517+
proxy_string, proxy_auth, proxy_user, proxy_pass,
518+
user_agent, disable_csp, enable_sync, user_data_dir,
519+
extension_zip, extension_dir)
520+
return webdriver.Chrome(executable_path=LOCAL_EDGEDRIVER,
521+
options=chrome_options)
522+
except Exception:
523+
try:
524+
return webdriver.Chrome(executable_path=LOCAL_EDGEDRIVER)
525+
except Exception:
526+
return webdriver.Edge(executable_path=LOCAL_EDGEDRIVER)
519527
else:
520-
return webdriver.Edge(capabilities=edge_capabilities)
528+
return webdriver.Edge()
521529
elif browser_name == constants.Browser.SAFARI:
522530
return webdriver.Safari()
523531
elif browser_name == constants.Browser.OPERA:
@@ -535,8 +543,8 @@ def get_local_driver(
535543
try:
536544
chrome_options = _set_chrome_options(
537545
downloads_path, headless,
538-
proxy_string, proxy_auth, proxy_user, proxy_pass, user_agent,
539-
disable_csp, enable_sync, user_data_dir,
546+
proxy_string, proxy_auth, proxy_user, proxy_pass,
547+
user_agent, disable_csp, enable_sync, user_data_dir,
540548
extension_zip, extension_dir)
541549
if LOCAL_CHROMEDRIVER and os.path.exists(LOCAL_CHROMEDRIVER):
542550
make_driver_executable_if_not(LOCAL_CHROMEDRIVER)

seleniumbase/fixtures/base_case.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,13 @@ def is_downloaded_file_present(self, file):
17041704

17051705
def assert_downloaded_file(self, file):
17061706
""" Asserts that the file exists in the Downloads Folder. """
1707-
assert os.path.exists(self.get_path_of_downloaded_file(file))
1707+
self.assertTrue(os.path.exists(self.get_path_of_downloaded_file(file)),
1708+
"File [%s] was not found in the downloads folder [%s]!"
1709+
"" % (file, self.get_downloads_folder()))
1710+
if self.demo_mode:
1711+
messenger_post = ("ASSERT DOWNLOADED FILE: [%s]" % file)
1712+
js_utils.post_messenger_success_message(
1713+
self.driver, messenger_post, self.message_duration)
17081714

17091715
def assert_true(self, expr, msg=None):
17101716
self.assertTrue(expr, msg=msg)
@@ -1736,7 +1742,11 @@ def assert_not_equal(self, first, second, msg=None):
17361742

17371743
def assert_title(self, title):
17381744
""" Asserts that the web page title matches the expected title. """
1739-
assert self.get_title() == title
1745+
expected = title
1746+
actual = self.get_title()
1747+
self.assertEqual(expected, actual, "Expected page title [%s] "
1748+
"does not match the actual page title [%s]!"
1749+
"" % (expected, actual))
17401750
if self.demo_mode:
17411751
messenger_post = ("ASSERT TITLE: {%s}" % title)
17421752
js_utils.post_messenger_success_message(

seleniumbase/utilities/selenium_ide/objectify.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ def remove_extra_slashes(selector):
9090
if selector.count('\\"') > 0:
9191
if selector.count('\\"') == selector.count('"'):
9292
selector = selector.replace('\\"', '"')
93-
elif (selector.count('\\"') == selector[1:-1].count('"') and
94-
"'" not in selector[1:-1]):
93+
elif (selector.count('\\"') == selector[1:-1].count('"') and (
94+
"'" not in selector[1:-1])):
9595
selector = "'" + selector[1:-1].replace('\\"', '"') + "'"
9696
else:
9797
pass
9898
if selector.count("\\'") > 0:
9999
if selector.count("\\'") == selector.count("'"):
100100
selector = selector.replace("\\'", "'")
101-
elif (selector.count("\\'") == selector[1:-1].count("'") and
102-
'"' not in selector[1:-1]):
101+
elif (selector.count("\\'") == selector[1:-1].count("'") and (
102+
'"' not in selector[1:-1])):
103103
selector = '"' + selector[1:-1].replace("\\'", "'") + '"'
104104
else:
105105
pass

seleniumbase/virtual_display/easyprocess.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ def __init__(self, cmd, ubuntu_package=None, url=None,
115115
def __repr__(self):
116116
msg = ('<%s cmd_param=%s cmd=%s oserror=%s return_code=%s'
117117
' stdout="%s" stderr="%s" timeout_happened=%s>' % (
118-
self.__class__.__name__,
119-
self.cmd_param,
120-
self.cmd,
121-
self.oserror,
122-
self.return_code,
123-
self.stdout,
124-
self.stderr,
125-
self.timeout_happened,
118+
self.__class__.__name__,
119+
self.cmd_param,
120+
self.cmd,
121+
self.oserror,
122+
self.return_code,
123+
self.stdout,
124+
self.stderr,
125+
self.timeout_happened,
126126
))
127127
return msg
128128

seleniumbase/virtual_display/xvfb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def check_installed(cls):
3737

3838
@property
3939
def _cmd(self):
40-
cmd = [
41-
dict(black='-br', white='-wr')[self.bgcolor],
40+
cmd = [dict(black='-br', white='-wr')[self.bgcolor],
4241
'-nolisten',
4342
'tcp',
4443
'-screen',

setup.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,48 @@
44
"""
55

66
from setuptools import setup, find_packages # noqa
7-
from os import path
7+
import os
8+
import sys
89

910

10-
this_directory = path.abspath(path.dirname(__file__))
11+
this_directory = os.path.abspath(os.path.dirname(__file__))
1112
long_description = None
1213
try:
13-
with open(path.join(this_directory, 'README.md'), 'rb') as f:
14+
with open(os.path.join(this_directory, 'README.md'), 'rb') as f:
1415
long_description = f.read().decode('utf-8')
1516
except IOError:
1617
long_description = 'Reliable Browser Automation & Testing Framework'
1718

19+
if sys.argv[-1] == 'publish':
20+
reply = None
21+
input_method = input
22+
if not sys.version_info[0] >= 3:
23+
input_method = raw_input # noqa
24+
reply = str(input_method(
25+
'>>> Confirm release PUBLISH to PyPI? (yes/no): ')).lower().strip()
26+
if reply == 'yes':
27+
print("\n*** Checking code health with flake8:\n")
28+
flake8_status = os.system("flake8 --exclude=temp")
29+
if flake8_status != 0:
30+
print("\nWARNING! Fix flake8 issues before publishing to PyPI!\n")
31+
sys.exit()
32+
else:
33+
print("*** No flake8 issues detected. Continuing...")
34+
print("\n*** Rebuilding distribution packages: ***\n")
35+
os.system('rm -f dist/*.egg; rm -f dist/*.tar.gz; rm -f dist/*.whl')
36+
os.system('python setup.py sdist bdist_wheel') # Create new tar/wheel
37+
print("\n*** Installing twine: *** (Required for PyPI uploads)\n")
38+
os.system("python -m pip install 'twine>=1.14.0'")
39+
print("\n*** Publishing The Release to PyPI: ***\n")
40+
os.system('python -m twine upload dist/*') # Requires ~/.pypirc Keys
41+
print("\n*** The Release was PUBLISHED SUCCESSFULLY to PyPI! :) ***\n")
42+
else:
43+
print("\n>>> The Release was NOT PUBLISHED to PyPI! <<<\n")
44+
sys.exit()
45+
1846
setup(
1947
name='seleniumbase',
20-
version='1.31.5',
48+
version='1.31.6',
2149
description='Fast, Easy, and Reliable Browser Automation & Testing.',
2250
long_description=long_description,
2351
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)