Skip to content

Reliability and other improvements #842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,14 @@ nosetests test_suite.py --report

See: [https://docs.qameta.io/allure/](https://docs.qameta.io/allure/#_pytest)

SeleniumBase no longer includes ``allure-pytest`` as part of installed dependencies. If you want to use it, install it first:

```bash
pip install allure-pytest
```

Now your tests can create Allure results files, which can be processed by Allure Reports.

```bash
pytest test_suite.py --alluredir=allure_results
```
Expand Down
4 changes: 1 addition & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
vmImage: 'Ubuntu-20.04'
strategy:
matrix:
Python2.7:
python.version: '2.7'
Python3.5:
python.version: '3.5'
Python3.6:
Expand All @@ -23,7 +21,7 @@ jobs:
python.version: '3.8'
Python3.9:
python.version: '3.9'
maxParallel: 6
maxParallel: 5

steps:
- task: UsePythonVersion@0
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
regex>=2020.11.13
regex>=2021.3.17
tqdm>=4.59.0
livereload==2.6.3;python_version>="3.6"
joblib==1.0.1;python_version>="3.6"
Expand Down
15 changes: 8 additions & 7 deletions examples/edge_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
This test is only for Microsoft Edge (Chromium)!
(Tested on Edge Version 89.0.774.54)
"""
from seleniumbase import BaseCase

Expand All @@ -12,10 +13,10 @@ def test_edge(self):
print(' (Run this test using "--edge" or "--browser=edge")')
self.skip('Use "--edge" or "--browser=edge"')
self.open("edge://settings/help")
self.assert_element('img[alt="Edge logo"] + span')
self.highlight('#section_about div + div')
self.highlight('#section_about div + div > div')
self.highlight('img[alt="Edge logo"]')
self.highlight('img[alt="Edge logo"] + span')
self.highlight('#section_about div + div > div + div')
self.highlight('#section_about div + div > div + div + div > div')
self.highlight('div[role="main"]')
self.highlight('img[srcset*="logo"]')
self.assert_text("Microsoft Edge", 'img[srcset*="logo"] + div')
self.highlight('img[srcset*="logo"] + div span:nth-of-type(1)')
self.highlight('img[srcset*="logo"] + div span:nth-of-type(2)')
self.highlight('span[aria-live="assertive"]')
self.highlight('a[href*="chromium"]')
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ packaging>=20.9
setuptools>=44.1.1;python_version<"3.5"
setuptools>=50.3.2;python_version>="3.5" and python_version<"3.6"
setuptools>=54.1.2;python_version>="3.6"
setuptools-scm>=5.0.2
setuptools-scm==5.0.2;python_version<"3.6"
setuptools-scm>=6.0.1;python_version>="3.6"
wheel>=0.36.2
attrs>=20.3.0
PyYAML>=5.4.1;python_version>="3.6"
Expand Down Expand Up @@ -80,8 +81,6 @@ Pillow==8.1.2;python_version>="3.6"
rich==9.13.0;python_version>="3.6" and python_version<"4.0"
tornado==5.1.1;python_version<"3.5"
tornado==6.1;python_version>="3.5"
allure-pytest==2.8.22;python_version<"3.5"
allure-pytest==2.8.36;python_version>="3.5"
pdfminer.six==20191110;python_version<"3.5"
pdfminer.six==20201018;python_version>="3.5"

Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "1.58.1"
__version__ = "1.58.2"
6 changes: 3 additions & 3 deletions seleniumbase/console_scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ def show_install_usage():
print(" sbase install chromedriver")
print(" sbase install geckodriver")
print(" sbase install edgedriver")
print(" sbase install chromedriver 88")
print(" sbase install chromedriver 88.0.4324.96")
print(" sbase install chromedriver 89")
print(" sbase install chromedriver 89.0.4389.23")
print(" sbase install chromedriver latest")
print(" sbase install chromedriver -p")
print(" sbase install chromedriver latest -p")
print(" sbase install edgedriver 88.0.705.74")
print(" sbase install edgedriver 89.0.774.54")
print(" Output:")
print(" Installs the chosen webdriver to seleniumbase/drivers/")
print(" (chromedriver is required for Chrome automation)")
Expand Down
13 changes: 7 additions & 6 deletions seleniumbase/console_scripts/sb_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
sbase install chromedriver
sbase install geckodriver
sbase install edgedriver
sbase install chromedriver 88.0.4324.96
sbase install chromedriver 88
sbase install chromedriver 89.0.4389.23
sbase install chromedriver 89
sbase install chromedriver latest
sbase install chromedriver -p
sbase install chromedriver latest -p
sbase install edgedriver 88.0.705.63
sbase install edgedriver 89.0.774.54
Output:
Installs the chosen webdriver to seleniumbase/drivers/
(chromedriver is required for Chrome automation)
Expand All @@ -43,8 +43,8 @@
LOCAL_PATH = "/usr/local/bin/" # On Mac and Linux systems
DEFAULT_CHROMEDRIVER_VERSION = "2.44" # (Specify "latest" to get the latest)
DEFAULT_GECKODRIVER_VERSION = "v0.29.0"
DEFAULT_EDGEDRIVER_VERSION = "88.0.705.63" # (Looks for LATEST_STABLE first)
DEFAULT_OPERADRIVER_VERSION = "v.84.0.4147.89"
DEFAULT_EDGEDRIVER_VERSION = "89.0.774.54" # (Looks for LATEST_STABLE first)
DEFAULT_OPERADRIVER_VERSION = "v.88.0.4324.104"


def invalid_run_command():
Expand All @@ -61,7 +61,8 @@ def invalid_run_command():
exp += " Example:\n"
exp += " seleniumbase install chromedriver\n"
exp += " seleniumbase install geckodriver\n"
exp += " seleniumbase install chromedriver 76.0.3809.126\n"
exp += " seleniumbase install chromedriver 89\n"
exp += " seleniumbase install chromedriver 89.0.4389.23\n"
exp += " seleniumbase install chromedriver latest\n"
exp += " seleniumbase install chromedriver -p\n"
exp += " seleniumbase install chromedriver latest -p\n"
Expand Down
27 changes: 19 additions & 8 deletions seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,9 @@ def open_new_window(self, switch_to=True):
time.sleep(0.01)
if switch_to:
self.switch_to_window(len(self.driver.window_handles) - 1)
time.sleep(0.01)
if self.browser == "safari":
self.wait_for_ready_state_complete()

def switch_to_window(self, window, timeout=None):
self.__check_scope()
Expand Down Expand Up @@ -3149,33 +3152,35 @@ def assert_downloaded_file(self, file, timeout=None, browser=False):
start_ms = time.time() * 1000.0
stop_ms = start_ms + (timeout * 1000.0)
downloaded_file_path = self.get_path_of_downloaded_file(file, browser)
found = False
for x in range(int(timeout)):
shared_utils.check_if_time_limit_exceeded()
try:
self.assertTrue(
os.path.exists(downloaded_file_path),
"File [%s] was not found in the downloads folder [%s]!"
"" % (file, self.get_downloads_folder()))
if self.demo_mode:
messenger_post = ("ASSERT DOWNLOADED FILE: [%s]" % file)
js_utils.post_messenger_success_message(
self.driver, messenger_post, self.message_duration)
return
found = True
break
except Exception:
now_ms = time.time() * 1000.0
if now_ms >= stop_ms:
break
time.sleep(1)
if not os.path.exists(downloaded_file_path):
if not found and not os.path.exists(downloaded_file_path):
message = (
"File {%s} was not found in the downloads folder {%s} "
"after %s seconds! (Or the download didn't complete!)"
"" % (file, self.get_downloads_folder(), timeout))
page_actions.timeout_exception("NoSuchFileException", message)
if self.demo_mode:
messenger_post = ("ASSERT DOWNLOADED FILE: [%s]" % file)
js_utils.post_messenger_success_message(
self.driver, messenger_post, self.message_duration)
try:
js_utils.activate_jquery(self.driver)
js_utils.post_messenger_success_message(
self.driver, messenger_post, self.message_duration)
except Exception:
pass

def assert_true(self, expr, msg=None):
""" Asserts that the expression is True.
Expand Down Expand Up @@ -6920,6 +6925,12 @@ def setUp(self, masterqa_mode=False):
url = self.get_current_url()
if url is not None:
has_url = True
if (len(self.driver.window_handles) > 1):
while (len(self.driver.window_handles) > 1):
self.switch_to_window(
len(self.driver.window_handles) - 1)
self.driver.close()
self.switch_to_window(0)
if self._crumbs:
self.driver.delete_all_cookies()
except Exception:
Expand Down
17 changes: 13 additions & 4 deletions seleniumbase/fixtures/js_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,15 @@ def highlight_with_js_2(driver, message, selector, o_bs, msg_dur):
driver.execute_script(script)
time.sleep(0.0181)

post_messenger_success_message(driver, message, msg_dur)
try:
activate_jquery(driver)
post_messenger_success_message(driver, message, msg_dur)
except Exception:
pass

script = ("""document.querySelector('%s').style.boxShadow =
'%s';""" % (selector, o_bs))
script = (
"""document.querySelector('%s').style.boxShadow = '%s';""" % (
selector, o_bs))
driver.execute_script(script)


Expand Down Expand Up @@ -668,7 +673,11 @@ def highlight_with_jquery_2(driver, message, selector, o_bs, msg_dur):
driver.execute_script(script)
time.sleep(0.0181)

post_messenger_success_message(driver, message, msg_dur)
try:
activate_jquery(driver)
post_messenger_success_message(driver, message, msg_dur)
except Exception:
pass

script = """jQuery('%s').css('box-shadow', '%s');""" % (selector, o_bs)
driver.execute_script(script)
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
'setuptools>=44.1.1;python_version<"3.5"',
'setuptools>=50.3.2;python_version>="3.5" and python_version<"3.6"',
'setuptools>=54.1.2;python_version>="3.6"',
'setuptools-scm>=5.0.2',
'setuptools-scm==5.0.2;python_version<"3.6"',
'setuptools-scm>=6.0.1;python_version>="3.6"',
'wheel>=0.36.2',
'attrs>=20.3.0',
'PyYAML>=5.4.1;python_version>="3.6"',
Expand Down Expand Up @@ -185,8 +186,6 @@
'rich==9.13.0;python_version>="3.6" and python_version<"4.0"',
'tornado==5.1.1;python_version<"3.5"',
'tornado==6.1;python_version>="3.5"',
'allure-pytest==2.8.22;python_version<"3.5"',
'allure-pytest==2.8.36;python_version>="3.5"',
'pdfminer.six==20191110;python_version<"3.5"',
'pdfminer.six==20201018;python_version>="3.5"',
],
Expand Down