Skip to content

Commit 37a8d8e

Browse files
committed
Update an example script
1 parent 791eeb0 commit 37a8d8e

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

examples/upgrade_chromedriver.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
"""
22
This script installs the chromedriver version that matches your Chrome.
33
On newer versions of Python, you may replace "testdir" with "pytester".
4-
(Run with "pytest") / (For Linux/macOS systems only!)
4+
(Run with "pytest")
55
"""
66
import subprocess
7-
import sys
87

98

109
class TestUpgradeChromedriver:
@@ -80,22 +79,20 @@ def test_print_versions(self):
8079
return testdir
8180

8281
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!")
8682
# Find out if the installed chromedriver version works with Chrome
83+
subprocess.check_call(
84+
"seleniumbase get chromedriver latest", shell=True
85+
)
8786
testdir = self.basic_run(testdir)
88-
result = testdir.inline_run("--headless")
87+
result = testdir.inline_run("--headless", "-s") # Upgrades as needed
8988
try:
9089
assert result.matchreport("test_passing").passed
9190
except Exception:
9291
# Install the compatibility version of chromedriver
93-
subprocess.check_call(
94-
"seleniumbase get chromedriver 72.0.3626.69", 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")
92+
install_command = "seleniumbase get chromedriver 72.0.3626.69"
93+
subprocess.check_call(install_command, shell=True)
94+
testdir = self.upgrade_chromedriver(testdir)
95+
testdir.inline_run("--headless", "-s")
9996
# Print the final installed versions of chromedriver and Chrome
10097
testdir = self.print_versions_of_chromedriver_and_chrome(testdir)
101-
result = testdir.inline_run("--headless", "-s")
98+
testdir.inline_run("--headless", "-s")

0 commit comments

Comments
 (0)