Skip to content

Commit 92e49fe

Browse files
authored
Merge pull request #957 from seleniumbase/update-driver-installation
Update driver installation options
2 parents 69cb278 + da02a6b commit 92e49fe

File tree

8 files changed

+123
-12
lines changed

8 files changed

+123
-12
lines changed

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
regex>=2021.7.6
1+
regex>=2021.8.3
22
tqdm>=4.62.0
33
livereload==2.6.3;python_version>="3.6"
44
joblib==1.0.1;python_version>="3.6"

examples/upgrade_chromedriver.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
"""
2+
This script installs the chromedriver version that matches your Chrome.
3+
On newer versions of Python, you may replace "testdir" with "pytester".
4+
(Run with "pytest") / (For Linux/macOS systems only!)
5+
"""
6+
import subprocess
7+
import sys
8+
9+
10+
class UpgradeChromedriverTests():
11+
def basic_run(self, testdir):
12+
testdir.makepyfile(
13+
"""
14+
from seleniumbase import BaseCase
15+
class MyTestCase(BaseCase):
16+
def test_passing(self):
17+
pass
18+
"""
19+
)
20+
return testdir
21+
22+
def upgrade_chromedriver(self, testdir):
23+
testdir.makepyfile(
24+
"""
25+
import subprocess
26+
from seleniumbase import BaseCase
27+
class MyTestCase(BaseCase):
28+
def test_upgrade(self):
29+
chrome_version = self.get_chrome_version()
30+
major_chrome_ver = chrome_version.split(".")[0]
31+
chromedriver_ver = self.get_chromedriver_version()
32+
major_chromedriver_ver = chromedriver_ver.split(".")[0]
33+
if major_chromedriver_ver != major_chrome_ver:
34+
subprocess.check_call(
35+
"sbase install chromedriver %s" % major_chrome_ver,
36+
shell=True
37+
)
38+
"""
39+
)
40+
return testdir
41+
42+
def print_versions_of_chromedriver_and_chrome(self, testdir):
43+
testdir.makepyfile(
44+
"""
45+
from seleniumbase import BaseCase
46+
class MyTestCase(BaseCase):
47+
def test_print_versions(self):
48+
chrome_version = self.get_chrome_version()
49+
major_chrome_ver = chrome_version.split(".")[0]
50+
chromedriver_ver = self.get_chromedriver_version()
51+
major_chromedriver_ver = chromedriver_ver.split(".")[0]
52+
print(
53+
"\\n* Now using chromedriver %s with Chrome %s"
54+
% (chromedriver_ver, chrome_version)
55+
)
56+
if major_chromedriver_ver == major_chrome_ver:
57+
print(
58+
"* SUCCESS: "
59+
"The chromedriver version is compatible "
60+
"with Chrome!"
61+
)
62+
elif major_chromedriver_ver < major_chrome_ver:
63+
print("* !!! Version Mismatch !!!")
64+
print(
65+
"* The version of chromedriver is too low!\\n"
66+
"* Try upgrading to chromedriver %s manually:\\n"
67+
"* >>> sbase install chromedriver %s <<<"
68+
% (major_chrome_ver, major_chrome_ver)
69+
)
70+
else:
71+
print("* !!! Version Mismatch !!!")
72+
print(
73+
"* The version of chromedriver is too high!\\n"
74+
"* Try downgrading to chromedriver %s manually:\\n"
75+
"* >>> sbase install chromedriver %s <<<"
76+
% (major_chrome_ver, major_chrome_ver)
77+
)
78+
"""
79+
)
80+
return testdir
81+
82+
def test_upgrade_chromedriver(self, testdir):
83+
if "linux" not in sys.platform and "darwin" not in sys.platform:
84+
print("\n This script is for Linux/macOS systems only!")
85+
self.skip("This script is for Linux/macOS systems only!")
86+
# Find out if the installed chromedriver version works with Chrome
87+
testdir = self.basic_run(testdir)
88+
result = testdir.inline_run("--headless")
89+
try:
90+
assert result.matchreport("test_passing").passed
91+
except Exception:
92+
# Install the compatibility version of chromedriver
93+
subprocess.check_call(
94+
"seleniumbase install chromedriver 2.44", shell=True
95+
)
96+
# Upgrade chromedriver to match the installed version of Chrome
97+
testdir = self.upgrade_chromedriver(testdir)
98+
result = testdir.inline_run("--headless", "-s")
99+
# Print the final installed versions of chromedriver and Chrome
100+
testdir = self.print_versions_of_chromedriver_and_chrome(testdir)
101+
result = testdir.inline_run("--headless", "-s")

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ decorator==5.0.9;python_version>="3.5"
7979
ipython==5.10.0;python_version<"3.5"
8080
ipython==6.5.0;python_version>="3.5" and python_version<"3.6"
8181
ipython==7.16.1;python_version>="3.6" and python_version<"3.7"
82-
ipython==7.25.0;python_version>="3.7"
82+
ipython==7.26.0;python_version>="3.7"
8383
matplotlib-inline==0.1.2;python_version>="3.7"
8484
colorama==0.4.4
8585
platformdirs==2.0.2;python_version<"3.6"
@@ -96,7 +96,7 @@ toml==0.10.2
9696
Pillow==6.2.2;python_version<"3.5"
9797
Pillow==7.2.0;python_version>="3.5" and python_version<"3.6"
9898
Pillow==8.3.1;python_version>="3.6"
99-
rich==10.6.0;python_version>="3.6" and python_version<"4.0"
99+
rich==10.7.0;python_version>="3.6" and python_version<"4.0"
100100
tornado==5.1.1;python_version<"3.5"
101101
tornado==6.1;python_version>="3.5"
102102
pdfminer.six==20191110;python_version<"3.5"

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "1.63.20"
2+
__version__ = "1.63.21"

seleniumbase/console_scripts/ReadMe.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ SeleniumBase console scripts help you get things done more easily, such as insta
1919
(Drivers: ``chromedriver``, ``geckodriver``, ``edgedriver``,
2020
``iedriver``, ``operadriver``)
2121
(Versions: ``latest`` or a specific driver version.
22+
For chromedriver, you can also specify the major
23+
version int, or ``latest-1`` for latest minus 1.
2224
If none specified, installs the default version.)
2325

2426
* Examples:

seleniumbase/console_scripts/run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ def show_install_usage():
123123
print(" sbase install chromedriver 91")
124124
print(" sbase install chromedriver 91.0.4472.101")
125125
print(" sbase install chromedriver latest")
126+
print(" sbase install chromedriver latest-1")
126127
print(" sbase install chromedriver -p")
127128
print(" sbase install chromedriver latest -p")
128-
print(" sbase install edgedriver 91.0.864.67")
129+
print(" sbase install edgedriver 91.0.864.71")
129130
print(" Output:")
130131
print(" Installs the chosen webdriver to seleniumbase/drivers/")
131132
print(" (chromedriver is required for Chrome automation)")

seleniumbase/console_scripts/sb_install.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
sbase install chromedriver 91.0.4472.101
1717
sbase install chromedriver 91
1818
sbase install chromedriver latest
19+
sbase install chromedriver latest-1 # (Latest minus one)
1920
sbase install chromedriver -p
2021
sbase install chromedriver latest -p
2122
sbase install edgedriver 91.0.864.67
@@ -44,7 +45,7 @@
4445
LOCAL_PATH = "/usr/local/bin/" # On Mac and Linux systems
4546
DEFAULT_CHROMEDRIVER_VERSION = "2.44" # (Specify "latest" to get the latest)
4647
DEFAULT_GECKODRIVER_VERSION = "v0.29.1"
47-
DEFAULT_EDGEDRIVER_VERSION = "89.0.774.54" # (Looks for LATEST_STABLE first)
48+
DEFAULT_EDGEDRIVER_VERSION = "91.0.864.71" # (Looks for LATEST_STABLE first)
4849
DEFAULT_OPERADRIVER_VERSION = "v.88.0.4324.104"
4950

5051

@@ -62,8 +63,8 @@ def invalid_run_command():
6263
exp += " Example:\n"
6364
exp += " seleniumbase install chromedriver\n"
6465
exp += " seleniumbase install geckodriver\n"
65-
exp += " seleniumbase install chromedriver 89\n"
66-
exp += " seleniumbase install chromedriver 89.0.4389.23\n"
66+
exp += " seleniumbase install chromedriver 91\n"
67+
exp += " seleniumbase install chromedriver 91.0.4472.101\n"
6768
exp += " seleniumbase install chromedriver latest\n"
6869
exp += " seleniumbase install chromedriver -p\n"
6970
exp += " seleniumbase install chromedriver latest -p\n"
@@ -153,12 +154,15 @@ def main(override=None):
153154
use_version = DEFAULT_CHROMEDRIVER_VERSION
154155
get_latest = False
155156
get_v_latest = False
157+
get_latest_minus_one = False
156158
if num_args == 4 or num_args == 5:
157159
if "-p" not in sys.argv[3].lower():
158160
use_version = sys.argv[3]
159161
uv_low = use_version.lower()
160162
if uv_low == "latest":
161163
get_latest = True
164+
elif uv_low == "latest-1":
165+
get_latest_minus_one = True
162166
elif len(uv_low) < 4 and uv_low.isdigit() and int(uv_low) > 69:
163167
get_v_latest = True
164168
else:
@@ -181,12 +185,15 @@ def main(override=None):
181185
"Cannot determine which version of chromedriver to download!"
182186
)
183187
found_chromedriver = False
184-
if get_latest:
188+
if get_latest or get_latest_minus_one:
185189
url_request = requests_get(last)
186190
if url_request.ok:
187191
found_chromedriver = True
188192
use_version = url_request.text
189-
elif get_v_latest:
193+
if get_latest_minus_one:
194+
get_v_latest = True
195+
use_version = str(int(use_version.split('.')[0]) - 1)
196+
if get_v_latest:
190197
url_req = requests_get(last)
191198
if url_req.ok:
192199
latest_version = url_req.text

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
'ipython==5.10.0;python_version<"3.5"',
195195
'ipython==6.5.0;python_version>="3.5" and python_version<"3.6"',
196196
'ipython==7.16.1;python_version>="3.6" and python_version<"3.7"',
197-
'ipython==7.25.0;python_version>="3.7"',
197+
'ipython==7.26.0;python_version>="3.7"',
198198
'matplotlib-inline==0.1.2;python_version>="3.7"',
199199
"colorama==0.4.4",
200200
'platformdirs==2.0.2;python_version<"3.6"',
@@ -211,7 +211,7 @@
211211
'Pillow==6.2.2;python_version<"3.5"',
212212
'Pillow==7.2.0;python_version>="3.5" and python_version<"3.6"',
213213
'Pillow==8.3.1;python_version>="3.6"',
214-
'rich==10.6.0;python_version>="3.6" and python_version<"4.0"',
214+
'rich==10.7.0;python_version>="3.6" and python_version<"4.0"',
215215
'tornado==5.1.1;python_version<"3.5"',
216216
'tornado==6.1;python_version>="3.5"',
217217
'pdfminer.six==20191110;python_version<"3.5"',

0 commit comments

Comments
 (0)