Skip to content

Commit a2170a0

Browse files
committed
Improve error-handling around older driver versions
1 parent 9c923de commit a2170a0

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def test_anything(self):
4444
from selenium.common.exceptions import (
4545
ElementClickInterceptedException as ECI_Exception,
4646
ElementNotInteractableException as ENI_Exception,
47+
InvalidArgumentException,
4748
MoveTargetOutOfBoundsException,
4849
NoSuchElementException,
4950
NoSuchWindowException,
@@ -1968,11 +1969,11 @@ def hover_on_element(self, selector, by="css selector"):
19681969
install_sb = (
19691970
"seleniumbase install chromedriver %s" % major_chrome_version
19701971
)
1971-
if major_chromedriver_version < major_chrome_version:
1972+
if int(major_chromedriver_version) < int(major_chrome_version):
19721973
# Upgrading the driver is required for performing hover actions
19731974
message = (
1974-
"\n"
1975-
"You need a newer chromedriver to perform hover actions!\n"
1975+
"You need a newer version of\n"
1976+
"chromedriver to perform hover actions!\n"
19761977
"Your version of chromedriver is: %s\n"
19771978
"And your version of Chrome is: %s\n"
19781979
"You can fix this issue by running:\n>>> %s\n"
@@ -11371,6 +11372,41 @@ def __click_with_offset(
1137111372
"The offset must stay inside the target element!"
1137211373
)
1137311374
raise Exception(message)
11375+
except InvalidArgumentException as e:
11376+
if not self.browser == "chrome":
11377+
raise Exception(e)
11378+
driver_capabilities = self.driver.capabilities
11379+
if "version" in driver_capabilities:
11380+
chrome_version = driver_capabilities["version"]
11381+
else:
11382+
chrome_version = driver_capabilities["browserVersion"]
11383+
major_chrome_version = chrome_version.split(".")[0]
11384+
chrome_dict = self.driver.capabilities["chrome"]
11385+
chromedriver_version = chrome_dict["chromedriverVersion"]
11386+
chromedriver_version = chromedriver_version.split(" ")[0]
11387+
major_chromedriver_version = chromedriver_version.split(".")[0]
11388+
if (
11389+
int(major_chromedriver_version) >= 76
11390+
and int(major_chrome_version) >= 76
11391+
):
11392+
raise Exception(e)
11393+
install_sb = (
11394+
"seleniumbase install chromedriver %s" % major_chrome_version
11395+
)
11396+
if int(major_chromedriver_version) < int(major_chrome_version):
11397+
# Upgrading the driver is needed for performing canvas actions
11398+
message = (
11399+
"You need to upgrade to a newer\n"
11400+
"version of chromedriver to perform canvas actions!\n"
11401+
"Reason: github.com/SeleniumHQ/selenium/issues/7000"
11402+
"\nYour version of chromedriver is: %s\n"
11403+
"And your version of Chrome is: %s\n"
11404+
"You can fix this issue by running:\n>>> %s\n"
11405+
% (chromedriver_version, chrome_version, install_sb)
11406+
)
11407+
raise Exception(message)
11408+
else:
11409+
raise Exception(e)
1137411410
if self.demo_mode:
1137511411
self.__demo_mode_pause_if_active()
1137611412
elif self.slow_mode:

0 commit comments

Comments
 (0)