Skip to content

Commit 484c8a2

Browse files
authored
Merge pull request #1021 from seleniumbase/time-for-selenium4
SeleniumBase 2.0.0 with Selenium 4.0.0
2 parents 89b1878 + 95d0842 commit 484c8a2

File tree

6 files changed

+41
-27
lines changed

6 files changed

+41
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta property="og:image" content="https://seleniumbase.io/cdn/img/mac_sb_logo_5.png" />
66
<link rel="icon" href="https://seleniumbase.io/img/logo6.png" />
77

8-
<h2 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/sb_banner_2t.png" alt="SeleniumBase" title="SeleniumBase" width="530" /></a></h2>
8+
<h2 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/sb_banner_d.png" alt="SeleniumBase" title="SeleniumBase" width="530" /></a></h2>
99
<h4 align="center">Everything you need for web testing.</h4>
1010
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/releases">
1111
<img src="https://img.shields.io/github/v/release/seleniumbase/SeleniumBase.svg?color=2277EE" alt="Latest Release on GitHub" /></a> <a href="https://pypi.org/project/seleniumbase/">

requirements.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ urllib3==1.26.7
3131
requests==2.26.0;python_version<"3.5"
3232
requests==2.25.1;python_version>="3.5" and python_version<"3.6"
3333
requests==2.26.0;python_version>="3.6"
34-
selenium==3.141.0
34+
selenium==3.141.0;python_version<"3.7"
35+
selenium==4.0.0;python_version>="3.7"
36+
trio==0.19.0;python_version>="3.7"
37+
trio-websocket==0.9.2;python_version>="3.7"
38+
pyopenssl==21.0.0;python_version>="3.7"
3539
msedge-selenium-tools==3.141.3;python_version<"3.7"
3640
more-itertools==5.0.0;python_version<"3.5"
3741
more-itertools==8.10.0;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.67.1"
2+
__version__ = "2.0.0"

seleniumbase/core/browser_launcher.py

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,6 @@ def _set_chrome_options(
458458
return chrome_options
459459

460460

461-
def _set_safari_capabilities():
462-
from selenium.webdriver.safari.webdriver import DesiredCapabilities as SDC
463-
464-
safari_capabilities = SDC.SAFARI.copy()
465-
safari_capabilities["cleanSession"] = True
466-
return safari_capabilities
467-
468-
469461
def _set_firefox_options(
470462
downloads_path,
471463
headless,
@@ -1130,6 +1122,7 @@ def get_local_driver(
11301122
)
11311123
else:
11321124
if os.path.exists(LOCAL_GECKODRIVER):
1125+
warnings.simplefilter("ignore", category=DeprecationWarning)
11331126
return webdriver.Firefox(
11341127
executable_path=LOCAL_GECKODRIVER,
11351128
options=firefox_options,
@@ -1189,6 +1182,7 @@ def get_local_driver(
11891182
if not headless:
11901183
return webdriver.Ie(capabilities=ie_capabilities)
11911184
else:
1185+
warnings.simplefilter("ignore", category=DeprecationWarning)
11921186
return webdriver.Ie(
11931187
executable_path=LOCAL_HEADLESS_IEDRIVER,
11941188
capabilities=ie_capabilities,
@@ -1265,11 +1259,15 @@ def get_local_driver(
12651259
sb_install.main(override="edgedriver")
12661260
sys.argv = sys_args # Put back the original sys args
12671261

1262+
selenium4 = False
1263+
if sys.version_info[0] == 3 and sys.version_info[1] >= 7:
1264+
selenium4 = True
1265+
12681266
# For Microsoft Edge (Chromium) version 80 or higher
1269-
try:
1270-
from msedge.selenium_tools import Edge, EdgeOptions
1271-
except Exception:
1272-
os.system("pip install msedge-selenium-tools")
1267+
if selenium4:
1268+
Edge = webdriver.edge.webdriver.WebDriver
1269+
EdgeOptions = webdriver.edge.webdriver.Options
1270+
else:
12731271
from msedge.selenium_tools import Edge, EdgeOptions
12741272

12751273
if LOCAL_EDGEDRIVER and os.path.exists(LOCAL_EDGEDRIVER):
@@ -1401,18 +1399,26 @@ def get_local_driver(
14011399
chromium_arg_item = "--" + chromium_arg_item
14021400
if len(chromium_arg_item) >= 3:
14031401
edge_options.add_argument(chromium_arg_item)
1404-
capabilities = edge_options.to_capabilities()
1405-
capabilities["platform"] = ""
1406-
return Edge(
1407-
executable_path=LOCAL_EDGEDRIVER, capabilities=capabilities
1408-
)
1402+
if selenium4:
1403+
warnings.simplefilter("ignore", category=DeprecationWarning)
1404+
return Edge(
1405+
executable_path=LOCAL_EDGEDRIVER,
1406+
options=edge_options,
1407+
)
1408+
else:
1409+
capabilities = edge_options.to_capabilities()
1410+
capabilities["platform"] = ""
1411+
return Edge(
1412+
executable_path=LOCAL_EDGEDRIVER,
1413+
capabilities=capabilities,
1414+
)
14091415
elif browser_name == constants.Browser.SAFARI:
14101416
arg_join = " ".join(sys.argv)
14111417
if ("-n" in sys.argv) or (" -n=" in arg_join) or (arg_join == "-c"):
14121418
# Skip if multithreaded
14131419
raise Exception("Can't run Safari tests in multi-threaded mode!")
1414-
safari_capabilities = _set_safari_capabilities()
1415-
return webdriver.Safari(desired_capabilities=safari_capabilities)
1420+
warnings.simplefilter("ignore", category=DeprecationWarning)
1421+
return webdriver.safari.webdriver.WebDriver(quiet=False)
14161422
elif browser_name == constants.Browser.OPERA:
14171423
try:
14181424
if LOCAL_OPERADRIVER and os.path.exists(LOCAL_OPERADRIVER):
@@ -1539,6 +1545,8 @@ def get_local_driver(
15391545
if not headless or "linux" not in PLATFORM:
15401546
try:
15411547
if os.path.exists(LOCAL_CHROMEDRIVER):
1548+
warnings.simplefilter(
1549+
"ignore", category=DeprecationWarning)
15421550
driver = webdriver.Chrome(
15431551
executable_path=LOCAL_CHROMEDRIVER,
15441552
options=chrome_options,
@@ -1610,6 +1618,8 @@ def get_local_driver(
16101618
)
16111619
_mark_chromedriver_repaired()
16121620
if os.path.exists(LOCAL_CHROMEDRIVER):
1621+
warnings.simplefilter(
1622+
"ignore", category=DeprecationWarning)
16131623
driver = webdriver.Chrome(
16141624
executable_path=LOCAL_CHROMEDRIVER,
16151625
options=chrome_options,

seleniumbase/fixtures/base_case.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ def open(self, url):
153153
if ("http:") in c_url or ("https:") in c_url or ("file:") in c_url:
154154
if self.get_domain_url(url) != self.get_domain_url(c_url):
155155
self.open_new_window(switch_to=True)
156-
if self.browser == "safari" and url.startswith("data:"):
157-
url = re.escape(url)
158-
url = self.__escape_quotes_if_needed(url)
159-
self.execute_script("window.location.href='%s';" % url)
160156
else:
161157
self.driver.get(url)
162158
if settings.WAIT_FOR_RSC_ON_PAGE_LOADS:

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@
147147
'requests==2.26.0;python_version<"3.5"',
148148
'requests==2.25.1;python_version>="3.5" and python_version<"3.6"',
149149
'requests==2.26.0;python_version>="3.6"',
150-
"selenium==3.141.0",
150+
'selenium==3.141.0;python_version<"3.7"',
151+
'selenium==4.0.0;python_version>="3.7"',
152+
'trio==0.19.0;python_version>="3.7"',
153+
'trio-websocket==0.9.2;python_version>="3.7"',
154+
'pyopenssl==21.0.0;python_version>="3.7"',
151155
'msedge-selenium-tools==3.141.3;python_version<"3.7"',
152156
'more-itertools==5.0.0;python_version<"3.5"',
153157
'more-itertools==8.10.0;python_version>="3.5"',

0 commit comments

Comments
 (0)