Merge pull request #1021 from seleniumbase/time-for-selenium4

SeleniumBase 2.0.0 with Selenium 4.0.0
This commit is contained in:
Michael Mintz 2021-10-16 01:34:21 -04:00 committed by GitHub
commit 484c8a21a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 27 deletions

View File

@ -5,7 +5,7 @@
<meta property="og:image" content="https://seleniumbase.io/cdn/img/mac_sb_logo_5.png" />
<link rel="icon" href="https://seleniumbase.io/img/logo6.png" />
<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>
<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>
<h4 align="center">Everything you need for web testing.</h4>
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/releases">
<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/">

View File

@ -31,7 +31,11 @@ urllib3==1.26.7
requests==2.26.0;python_version<"3.5"
requests==2.25.1;python_version>="3.5" and python_version<"3.6"
requests==2.26.0;python_version>="3.6"
selenium==3.141.0
selenium==3.141.0;python_version<"3.7"
selenium==4.0.0;python_version>="3.7"
trio==0.19.0;python_version>="3.7"
trio-websocket==0.9.2;python_version>="3.7"
pyopenssl==21.0.0;python_version>="3.7"
msedge-selenium-tools==3.141.3;python_version<"3.7"
more-itertools==5.0.0;python_version<"3.5"
more-itertools==8.10.0;python_version>="3.5"

View File

@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "1.67.1"
__version__ = "2.0.0"

View File

@ -458,14 +458,6 @@ def _set_chrome_options(
return chrome_options
def _set_safari_capabilities():
from selenium.webdriver.safari.webdriver import DesiredCapabilities as SDC
safari_capabilities = SDC.SAFARI.copy()
safari_capabilities["cleanSession"] = True
return safari_capabilities
def _set_firefox_options(
downloads_path,
headless,
@ -1130,6 +1122,7 @@ def get_local_driver(
)
else:
if os.path.exists(LOCAL_GECKODRIVER):
warnings.simplefilter("ignore", category=DeprecationWarning)
return webdriver.Firefox(
executable_path=LOCAL_GECKODRIVER,
options=firefox_options,
@ -1189,6 +1182,7 @@ def get_local_driver(
if not headless:
return webdriver.Ie(capabilities=ie_capabilities)
else:
warnings.simplefilter("ignore", category=DeprecationWarning)
return webdriver.Ie(
executable_path=LOCAL_HEADLESS_IEDRIVER,
capabilities=ie_capabilities,
@ -1265,11 +1259,15 @@ def get_local_driver(
sb_install.main(override="edgedriver")
sys.argv = sys_args # Put back the original sys args
selenium4 = False
if sys.version_info[0] == 3 and sys.version_info[1] >= 7:
selenium4 = True
# For Microsoft Edge (Chromium) version 80 or higher
try:
from msedge.selenium_tools import Edge, EdgeOptions
except Exception:
os.system("pip install msedge-selenium-tools")
if selenium4:
Edge = webdriver.edge.webdriver.WebDriver
EdgeOptions = webdriver.edge.webdriver.Options
else:
from msedge.selenium_tools import Edge, EdgeOptions
if LOCAL_EDGEDRIVER and os.path.exists(LOCAL_EDGEDRIVER):
@ -1401,18 +1399,26 @@ def get_local_driver(
chromium_arg_item = "--" + chromium_arg_item
if len(chromium_arg_item) >= 3:
edge_options.add_argument(chromium_arg_item)
capabilities = edge_options.to_capabilities()
capabilities["platform"] = ""
return Edge(
executable_path=LOCAL_EDGEDRIVER, capabilities=capabilities
)
if selenium4:
warnings.simplefilter("ignore", category=DeprecationWarning)
return Edge(
executable_path=LOCAL_EDGEDRIVER,
options=edge_options,
)
else:
capabilities = edge_options.to_capabilities()
capabilities["platform"] = ""
return Edge(
executable_path=LOCAL_EDGEDRIVER,
capabilities=capabilities,
)
elif browser_name == constants.Browser.SAFARI:
arg_join = " ".join(sys.argv)
if ("-n" in sys.argv) or (" -n=" in arg_join) or (arg_join == "-c"):
# Skip if multithreaded
raise Exception("Can't run Safari tests in multi-threaded mode!")
safari_capabilities = _set_safari_capabilities()
return webdriver.Safari(desired_capabilities=safari_capabilities)
warnings.simplefilter("ignore", category=DeprecationWarning)
return webdriver.safari.webdriver.WebDriver(quiet=False)
elif browser_name == constants.Browser.OPERA:
try:
if LOCAL_OPERADRIVER and os.path.exists(LOCAL_OPERADRIVER):
@ -1539,6 +1545,8 @@ def get_local_driver(
if not headless or "linux" not in PLATFORM:
try:
if os.path.exists(LOCAL_CHROMEDRIVER):
warnings.simplefilter(
"ignore", category=DeprecationWarning)
driver = webdriver.Chrome(
executable_path=LOCAL_CHROMEDRIVER,
options=chrome_options,
@ -1610,6 +1618,8 @@ def get_local_driver(
)
_mark_chromedriver_repaired()
if os.path.exists(LOCAL_CHROMEDRIVER):
warnings.simplefilter(
"ignore", category=DeprecationWarning)
driver = webdriver.Chrome(
executable_path=LOCAL_CHROMEDRIVER,
options=chrome_options,

View File

@ -153,10 +153,6 @@ class BaseCase(unittest.TestCase):
if ("http:") in c_url or ("https:") in c_url or ("file:") in c_url:
if self.get_domain_url(url) != self.get_domain_url(c_url):
self.open_new_window(switch_to=True)
if self.browser == "safari" and url.startswith("data:"):
url = re.escape(url)
url = self.__escape_quotes_if_needed(url)
self.execute_script("window.location.href='%s';" % url)
else:
self.driver.get(url)
if settings.WAIT_FOR_RSC_ON_PAGE_LOADS:

View File

@ -147,7 +147,11 @@ setup(
'requests==2.26.0;python_version<"3.5"',
'requests==2.25.1;python_version>="3.5" and python_version<"3.6"',
'requests==2.26.0;python_version>="3.6"',
"selenium==3.141.0",
'selenium==3.141.0;python_version<"3.7"',
'selenium==4.0.0;python_version>="3.7"',
'trio==0.19.0;python_version>="3.7"',
'trio-websocket==0.9.2;python_version>="3.7"',
'pyopenssl==21.0.0;python_version>="3.7"',
'msedge-selenium-tools==3.141.3;python_version<"3.7"',
'more-itertools==5.0.0;python_version<"3.5"',
'more-itertools==8.10.0;python_version>="3.5"',