Skip to content

Commit bc502db

Browse files
authoredFeb 6, 2021
Merge pull request #804 from seleniumbase/plugin-compatibility-and-more
Plugin compatibility, Firefox add-ons, and more
2 parents 66a96d3 + 89a8937 commit bc502db

File tree

10 files changed

+39
-22
lines changed

10 files changed

+39
-22
lines changed
 

‎README.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,19 @@ Tests are run with "pytest". Browsers are controlled by WebDriver.
5050
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/ReadMe.md">🛂 MasterQA</a>
5151
</p>
5252

53-
✅ Has a [complete API](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md) for Web-UI testing.<br />
54-
✅ Expands pytest [command-line options](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md).<br />
55-
✅ Includes [scripts](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md) for driver management.<br />
56-
✅ Includes tools for [dashboards & reports](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md).<br />
53+
✅ Get set up in minutes. Deploy anywhere.<br />
54+
✅ Build Web-UI tests with a [complete API](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md).<br />
55+
✅ Generate [test reports and dashboards](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md).<br />
5756

5857
--------
5958

60-
<p align="center">(Example: <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_swag_labs.py">test_swag_labs.py</a> in Demo Mode.)</p>
59+
<p align="left">(Example: <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py">my_first_test.py</a> in Demo Mode.)</p>
6160

6261
```bash
63-
pytest test_swag_labs.py --demo
62+
pytest my_first_test.py --demo
6463
```
6564

66-
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_swag_labs.py"><img src="https://seleniumbase.io/cdn/gif/swag_demo_2.gif" alt="SeleniumBase Demo Mode" title="SeleniumBase Demo Mode" /></a></p>
65+
<p align="left"><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_swag_labs.py"><img src="https://seleniumbase.io/cdn/gif/my_first_test_4.gif" alt="SeleniumBase Demo Mode" title="SeleniumBase Demo Mode" width="400" /></a></p>
6766

6867
<a id="python_installation"></a>
6968
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Python Setup:</h2>
@@ -181,7 +180,7 @@ pytest test_swag_labs.py
181180
pytest my_first_test.py --demo
182181
```
183182
184-
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py"><img src="https://seleniumbase.io/cdn/gif/my_first_test_1.gif" title="SeleniumBase" /></a>
183+
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py"><img src="https://seleniumbase.io/cdn/gif/my_first_test_4.gif" title="SeleniumBase" /></a>
185184
186185
<b>Here's the code for [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py):</b>
187186
@@ -382,7 +381,7 @@ The code above will leave your browser window open in case there's a failure. (i
382381
--incognito # (Enable Chrome's Incognito mode.)
383382
--guest # (Enable Chrome's Guest mode.)
384383
--devtools # (Open Chrome's DevTools when the browser opens.)
385-
--reuse-session # (Reuse the browser session between tests.)
384+
--reuse-session | --rs # (Reuse browser session between tests.)
386385
--crumbs # (Delete all cookies between tests reusing a session.)
387386
--maximize-window # (Start tests with the web browser window maximized.)
388387
--save-screenshot # (Save a screenshot at the end of each test.)

‎docs/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Jinja2==2.11.3
66
readme-renderer==28.0
77
pymdown-extensions==8.1.1
88
mkdocs==1.1.2
9-
mkdocs-material==6.2.7
9+
mkdocs-material==6.2.8
1010
mkdocs-simple-hooks==0.1.2
1111
mkdocs-material-extensions==1.0.1
1212
mkdocs-minify-plugin==0.4.0

‎examples/ReadMe.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Run an example test in Demo Mode: (highlight assertions)
3333
pytest my_first_test.py --demo
3434
```
3535

36-
<img src="https://seleniumbase.io/cdn/gif/my_first_test_1.gif" title="SeleniumBase Demo Mode" /><br />
36+
<img src="https://seleniumbase.io/cdn/gif/my_first_test_4.gif" title="SeleniumBase Demo Mode" /><br />
3737

3838
Run a different example in Demo Mode:
3939

‎help_docs/method_summary.md

+2
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ self.wait_for_angularjs(timeout=None)
208208
self.sleep(seconds)
209209
# Duplicates: self.wait(seconds)
210210

211+
self.install_addon(xpi_file)
212+
211213
self.activate_design_mode()
212214

213215
self.deactivate_design_mode()

‎requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pymysql==0.10.1;python_version<"3.6"
7171
pymysql==1.0.2;python_version>="3.6"
7272
coverage==5.4
7373
brython==3.9.1
74-
pyotp==2.5.1
74+
pyotp==2.6.0
7575
boto==2.49.0
7676
cffi==1.14.4
7777
toml==0.10.2
@@ -86,6 +86,6 @@ pyflakes==2.2.0;python_version>="3.5"
8686
tornado==5.1.1;python_version<"3.5"
8787
tornado==6.1;python_version>="3.5"
8888
allure-pytest==2.8.22;python_version<"3.5"
89-
allure-pytest==2.8.32;python_version>="3.5"
89+
allure-pytest==2.8.33;python_version>="3.5"
9090
pdfminer.six==20191110;python_version<"3.5"
9191
pdfminer.six==20201018;python_version>="3.5"

‎seleniumbase/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "1.55.0"
2+
__version__ = "1.55.1"

‎seleniumbase/console_scripts/run.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def show_options():
575575
print('--headless (Run tests headlessly. Default mode on Linux OS.)')
576576
print('--demo (Slow down and visually see test actions as they occur.)')
577577
print('--slow (Slow down the automation. Faster than using Demo Mode.)')
578-
print('--reuse-session / --rs (Reuse the browser session between tests.)')
578+
print('--reuse-session / --rs (Reuse browser session between tests.)')
579579
print('--crumbs (Delete all cookies between tests reusing a session.)')
580580
print('--maximize (Start tests with the web browser window maximized.)')
581581
print('--dashboard (Enable the SeleniumBase Dashboard at dashboard.html)')

‎seleniumbase/fixtures/base_case.py

+12
Original file line numberDiff line numberDiff line change
@@ -2184,6 +2184,18 @@ def sleep(self, seconds):
21842184
break
21852185
time.sleep(0.2)
21862186

2187+
def install_addon(self, xpi_file):
2188+
""" Installs a Firefox add-on instantly at run-time.
2189+
@Params
2190+
xpi_file - A file archive in .xpi format. """
2191+
if self.browser != "firefox":
2192+
raise Exception(
2193+
"install_addon(xpi_file) is for Firefox ONLY!\n"
2194+
"To load a Chrome extension, use the comamnd-line:\n"
2195+
"--extension_zip=CRX_FILE OR --extension_dir=DIR")
2196+
xpi_path = os.path.abspath(xpi_file)
2197+
self.driver.install_addon(xpi_path, temporary=True)
2198+
21872199
def activate_design_mode(self):
21882200
# Activate Chrome's Design Mode, which lets you edit a site directly.
21892201
# See: https://twitter.com/sulco/status/1177559150563344384

‎seleniumbase/plugins/pytest_plugin.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def pytest_addoption(parser):
6767
--incognito (Enable Chrome's Incognito mode.)
6868
--guest (Enable Chrome's Guest mode.)
6969
--devtools (Open Chrome's DevTools when the browser opens.)
70-
--reuse-session / --rs (Reuse the browser session between tests.)
70+
--reuse-session | --rs (Reuse browser session between tests.)
7171
--crumbs (Delete all cookies between tests reusing a session.)
7272
--maximize (Start tests with the web browser window maximized.)
7373
--save-screenshot (Save a screenshot at the end of each test.)
@@ -856,7 +856,7 @@ def pytest_terminal_summary(terminalreporter):
856856
def pytest_unconfigure():
857857
""" This runs after all tests have completed with pytest. """
858858
proxy_helper.remove_proxy_zip_if_present()
859-
if sb_config.reuse_session:
859+
if hasattr(sb_config, 'reuse_session') and sb_config.reuse_session:
860860
# Close the shared browser session
861861
if sb_config.shared_driver:
862862
try:
@@ -866,10 +866,13 @@ def pytest_unconfigure():
866866
except Exception:
867867
pass
868868
sb_config.shared_driver = None
869-
log_helper.archive_logs_if_set(sb_config.log_path, sb_config.archive_logs)
869+
if hasattr(sb_config, 'log_path'):
870+
log_helper.archive_logs_if_set(
871+
sb_config.log_path, sb_config.archive_logs)
870872

871873
# Dashboard post-processing: Disable time-based refresh and stamp complete
872-
if sb_config.dashboard and not sb_config._only_unittest:
874+
if hasattr(sb_config, 'dashboard') and (
875+
sb_config.dashboard and not sb_config._only_unittest):
873876
stamp = ""
874877
if sb_config._dash_is_html_report:
875878
# (If the Dashboard URL is the same as the HTML Report URL:)
@@ -985,7 +988,8 @@ def pytest_runtest_makereport(item, call):
985988
pytest_html = item.config.pluginmanager.getplugin('html')
986989
outcome = yield
987990
report = outcome.get_result()
988-
if pytest_html and report.when == 'call':
991+
if pytest_html and report.when == 'call' and (
992+
hasattr(sb_config, 'dashboard')):
989993
if sb_config.dashboard and not sb_config._sbase_detected:
990994
test_id, display_id = _get_test_ids_(item)
991995
r_outcome = report.outcome

‎setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
'pymysql==1.0.2;python_version>="3.6"',
176176
'coverage==5.4',
177177
'brython==3.9.1',
178-
'pyotp==2.5.1',
178+
'pyotp==2.6.0',
179179
'boto==2.49.0',
180180
'cffi==1.14.4',
181181
'toml==0.10.2',
@@ -190,7 +190,7 @@
190190
'tornado==5.1.1;python_version<"3.5"',
191191
'tornado==6.1;python_version>="3.5"',
192192
'allure-pytest==2.8.22;python_version<"3.5"',
193-
'allure-pytest==2.8.32;python_version>="3.5"',
193+
'allure-pytest==2.8.33;python_version>="3.5"',
194194
'pdfminer.six==20191110;python_version<"3.5"',
195195
'pdfminer.six==20201018;python_version>="3.5"',
196196
],

0 commit comments

Comments
 (0)
Please sign in to comment.