Skip to content

Commit 202956f

Browse files
authored
Merge pull request #733 from seleniumbase/update-firefox-options-and-presenter
Update Firefox preferences and Presenter
2 parents f7a20dd + 2860a41 commit 202956f

File tree

10 files changed

+201
-47
lines changed

10 files changed

+201
-47
lines changed

README.md

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,19 @@
66
<link rel="icon" href="https://seleniumbase.io/img/logo3a.png" />
77

88
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/">
9-
<img src="https://seleniumbase.io/cdn/img/fancy_logo_14.png" alt="SeleniumBase" title="SeleniumBase" width="300" />
9+
<img src="https://seleniumbase.io/cdn/img/super_logo_sb.png" alt="SeleniumBase" title="SeleniumBase" width="300" />
1010
</a></p>
11-
<p align="center"><b>The complete web automation library.</b></p>
12-
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/">
13-
<img src="https://seleniumbase.io/img/sb_logo_10.png" alt="SeleniumBase" width="152" /></a><a href="https://github.com/seleniumbase/SeleniumBase/">
14-
<img src="https://seleniumbase.io/cdn/img/sb_demo_site.png" alt="SeleniumBase" width="152" />
15-
</a></p>
16-
<p align="center">Powered by WebDriver APIs and pytest.</p>
11+
1712
<!-- View on GitHub -->
18-
<p align="center">
19-
<a href="https://github.com/seleniumbase/SeleniumBase/releases">
13+
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/releases">
2014
<img src="https://img.shields.io/github/v/release/seleniumbase/SeleniumBase.svg?color=2277EE" alt="Latest Release on GitHub" /></a> <a href="https://pypi.python.org/pypi/seleniumbase">
21-
<img src="https://img.shields.io/pypi/v/seleniumbase.svg?color=22AAEE" alt="Latest Release on PyPI" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/actions">
22-
<img src="https://github.com/seleniumbase/SeleniumBase/workflows/CI%20build/badge.svg" alt="SeleniumBase GitHub Actions" /></a> <a href="https://gitter.im/seleniumbase/SeleniumBase">
15+
<img src="https://img.shields.io/pypi/v/seleniumbase.svg?color=22AAEE" alt="Latest Release on PyPI" /></a> <a href="https://dev.azure.com/seleniumbase/seleniumbase/_build/latest?definitionId=1&branchName=master"> <img src="https://dev.azure.com/seleniumbase/seleniumbase/_apis/build/status/seleniumbase.SeleniumBase?branchName=master" alt="SeleniumBase Azure Pipelines" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/actions">
16+
<img src="https://github.com/seleniumbase/SeleniumBase/workflows/CI%20build/badge.svg" alt="SeleniumBase GitHub Actions" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/stargazers"> <img src="https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg?color=9A77EC" alt="SeleniumBase GitHub Stars" /></a> <a href="https://gitter.im/seleniumbase/SeleniumBase">
2317
<img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" alt="SeleniumBase" /></a> <a href="https://seleniumbase.io">
24-
<img src="https://img.shields.io/badge/docs-%20seleniumbase.io-22BBAA.svg" alt="SeleniumBase.io Docs" /></a>
25-
</p>
18+
<img src="https://img.shields.io/badge/docs-%20seleniumbase.io-22BBAA.svg" alt="SeleniumBase.io Docs" /></a></p>
2619

27-
<p>
28-
<b>SeleniumBase</b> is an all-in-one framework for reliable browser automation, end-to-end testing, reports, charts, presentations, website tours, and visual testing.
29-
Tests are run with <a href="https://docs.pytest.org/en/latest/index.html">pytest</a>. Browsers are controlled by <a href="https://www.w3.org/TR/webdriver2/#endpoints">WebDriver</a>.
30-
</p>
20+
<p><b>SeleniumBase</b> is a complete framework for browser automation, end-to-end testing, reports, charts, presentations, website tours, and visual testing.
21+
Tests are run with <a href="https://docs.pytest.org/en/latest/index.html">pytest</a>. Browsers are controlled by <a href="https://www.w3.org/TR/webdriver2/#endpoints">WebDriver</a>.</p>
3122

3223
<p align="center">
3324
<a href="#python_installation">🚀 Start</a> |
@@ -58,23 +49,21 @@ Tests are run with <a href="https://docs.pytest.org/en/latest/index.html">pytest
5849
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/ReadMe.md">🛂 MasterQA</a>
5950
</p>
6051

52+
* Uses reliable, smart-waiting code to prevent flaky tests.
53+
* Simplifies the process of creating UI tests for any website.
54+
* Includes [Plugins](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/plugins/pytest_plugin.py) for logging [test results and screenshots](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md).
55+
* Has versatile [Python methods](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md) and [command-line options](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md).
56+
6157
--------
6258

63-
<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_mobile_2.gif" alt="SeleniumBase Mobile Mode" title="SeleniumBase Mobile Mode" /></a></p>
59+
<p align="center">(Below: <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_swag_labs.py">test_swag_labs.py</a> using Demo Mode.)</p>
6460

6561
```bash
66-
pytest test_swag_labs.py --mobile
62+
pytest test_swag_labs.py --demo
6763
```
6864

69-
<p align="center">(Above: <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_swag_labs.py">test_swag_labs.py</a> in Mobile Mode.)</p>
70-
71-
<div><p align="center">(Below: Same test running in Demo Mode.)</p></div>
7265
<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>
7366

74-
```bash
75-
pytest test_swag_labs.py --demo
76-
```
77-
7867
--------
7968

8069
<a id="python_installation"></a>
@@ -326,7 +315,7 @@ For a full list of SeleniumBase features, <a href="https://github.com/seleniumba
326315
327316
328317
<a id="detailed_instructions"></a>
329-
<img src="https://seleniumbase.io/cdn/img/super_logo_sb.png" title="SeleniumBase" width="290">
318+
<img src="https://seleniumbase.io/img/sb_logo_10.png" title="SeleniumBase" width="290">
330319
331320
<h2><img src="https://seleniumbase.io/img/logo3a.png" title="SeleniumBase" width="32" /> Detailed Instructions:</h2>
332321
@@ -398,7 +387,7 @@ SeleniumBase provides additional ``pytest`` command-line options for tests:
398387
--proxy=USERNAME:PASSWORD@SERVER:PORT # (Use authenticated proxy server.)
399388
--agent=STRING # (Modify the web browser's User-Agent string.)
400389
--mobile # (Use the mobile device emulator while running tests.)
401-
--metrics=STRING # (Set mobile "CSSWidth,CSSHeight,PixelRatio".)
390+
--metrics=STRING # (Set mobile metrics: "CSSWidth,CSSHeight,PixelRatio".)
402391
--extension-zip=ZIP # (Load a Chrome Extension .zip|.crx, comma-separated.)
403392
--extension-dir=DIR # (Load a Chrome Extension directory, comma-separated.)
404393
--headless # (Run tests headlessly. Default mode on Linux OS.)
@@ -893,7 +882,7 @@ Additionally, you can use the ``@retry_on_exception()`` decorator to specificall
893882
</p>
894883
<p><div><a href="https://github.com/mdmintz">https://github.com/mdmintz</a></div></p>
895884
896-
<div><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/super_logo_sb.png" title="SeleniumBase" width="290" /></a></div>
885+
<div><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/fancy_logo_14.png" title="SeleniumBase" width="290" /></a></div>
897886
898887
<div><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-22BBCC.svg" title="SeleniumBase" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/releases"><img src="https://img.shields.io/github/repo-size/seleniumbase/seleniumbase.svg" title="SeleniumBase" alt="Repo Size" /></a> <a href="https://gitter.im/seleniumbase/SeleniumBase"><img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" title="SeleniumBase" alt="Join the chat!" /></a></div>
899888

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
regex>=2020.11.13
2-
tqdm>=4.51.0
2+
tqdm>=4.52.0
33
livereload==2.6.3;python_version>="3.6"
44
Markdown==3.3.3
55
readme-renderer==28.0
66
pymdown-extensions==8.0.1
77
mkdocs==1.1.2
8-
mkdocs-material==6.1.4
8+
mkdocs-material==6.1.5
99
mkdocs-simple-hooks==0.1.2
1010
mkdocs-material-extensions==1.0.1
1111
mkdocs-minify-plugin==0.3.0

examples/presenter/py_virtual_envs.py

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
from seleniumbase import BaseCase
2+
3+
4+
class PythonVirtualEnvPresentation(BaseCase):
5+
6+
def test_py_virtual_envs(self):
7+
self.create_presentation(theme="serif", transition="slide")
8+
self.add_slide(
9+
'<h2>Python Virtual Environments:</h2><br />\n'
10+
'<h2>What, Why, and How</h2><hr /><br />\n'
11+
'\n'
12+
'<h3>Presented by <b>Michael Mintz</b></h3>')
13+
self.add_slide(
14+
'<p><b>About me:</b></p>\n'
15+
'<ul>'
16+
'<li>I created the <b>SeleniumBase</b> framework.</li>'
17+
"<li>I'm currently the DevOps Lead at <b>iboss</b>.</li>"
18+
'</ul>\n',
19+
image="https://seleniumbase.io/other/iboss_booth.png")
20+
self.add_slide(
21+
'<p><b>Topics & tools covered by this presentation:</b></p>'
22+
'<hr /><br />\n'
23+
'<ul>'
24+
'<li>Overview of Virtual Environments</li>'
25+
'<li>Python package management</li>'
26+
'<li>Python 3 "venv"</li>'
27+
'<li>virtualenv / virtualenvwrapper</li>'
28+
'<li>pip / "pip install"</li>'
29+
'<li>requirements.txt files</li>'
30+
'<li>setup.py files</li>'
31+
'</ul>')
32+
self.add_slide(
33+
'<p><b>Topics & tools that are NOT covered here:</b></p><hr />\n'
34+
'<br /><div><ul>'
35+
'<li>"conda"</li>'
36+
'<li>"pipenv"</li>'
37+
'<li>"poetry"</li>'
38+
'<li>"pipx"</li>'
39+
'</ul></div><br />'
40+
'<p>(Other Python package management tools)</p>')
41+
self.add_slide(
42+
'<p><b>What is a Python virtual environment?</b></p><hr /><br />\n'
43+
'<p>A Python virtual environment is a partitioned directory'
44+
' where a Python interpreter, libraries/packages, and scripts'
45+
' can be installed and isolated from those installed in other'
46+
' virtual environments or the global environment.</p>')
47+
self.add_slide(
48+
'<p><b>Why should we use Python virtual environments?</b>'
49+
'</p><hr /><br />\n'
50+
'<p>We should use Python virtual environments because different'
51+
' Python projects can have conflicting Python dependencies that'
52+
' cannot coexist in the same env.</p>')
53+
self.add_slide(
54+
'<p><b>Why? - continued</b></p><hr /><br />\n'
55+
'<p>Example: Project A and Project B both depend on'
56+
' different versions of the same Python library!</p>'
57+
'<p>Therefore, installing the second project requirements'
58+
' would overwrite the first one, causing it to break.</p>',
59+
code=(
60+
'# Project A requirement:\n'
61+
'urllib3==1.25.3\n\n'
62+
'# Project B requirement:\n'
63+
'urllib3==1.26.2'))
64+
self.add_slide(
65+
'<p><b>Why? - continued</b></p><hr /><br />\n'
66+
'<p>It is also possible that Project A and Project B'
67+
' require different versions of Python installed!</p>',
68+
code=(
69+
'# Project A requirement:\n'
70+
'Python-3.8\n\n'
71+
'# Project B requirement:\n'
72+
'Python-2.7'))
73+
self.add_slide(
74+
'<p><b>How do we create and use Python virtual envs?</b>'
75+
'</p><hr /><br />\n'
76+
'<div><b>There are tools/scripts we can use:</b></div><br />'
77+
'<ul>'
78+
'<li>The Python 3 "venv" command</li>'
79+
'<li>virtualenv / virtualenvwrapper</li>'
80+
'</ul>')
81+
self.add_slide(
82+
'<p><b>Python 3 "venv"</b></p><hr /><br />\n'
83+
'"venv" creates virtual environments in the location where run'
84+
' (generally with Python projects).',
85+
code=(
86+
'# Mac / Linux\n'
87+
'python3 -m venv ENV_NAME\n'
88+
'source ENV_NAME/bin/activate\n\n'
89+
'# Windows\n'
90+
'py -m venv ENV_NAME\n'
91+
'call ENV_NAME\\Scripts\\activate\n\n'
92+
'# (Type "deactivate" to leave a virtual environment.)'))
93+
self.add_slide(
94+
'<p><b>"mkvirtualenv" (from virtualenvwrapper)</b></p><hr />\n'
95+
'<br />"mkvirtualenv" creates virtual environments in one place'
96+
' (generally in your home directory).',
97+
code=(
98+
'# Mac / Linux\n'
99+
'python3 -m pip install virtualenvwrapper\n'
100+
'export WORKON_HOME=$HOME/.virtualenvs\n'
101+
'source `which virtualenvwrapper.sh`\n'
102+
'mkvirtualenv ENV_NAME\n\n'
103+
'# Windows\n'
104+
'py -m pip install virtualenvwrapper-win\n'
105+
'mkvirtualenv ENV_NAME\n\n'
106+
'# (Type "deactivate" to leave a virtual environment.)'))
107+
self.add_slide(
108+
'<p><b>List of commands from virtualenvwrapper</b></p>'
109+
'<hr /><br />',
110+
code=(
111+
'# Creating a virtual environment:\n'
112+
'mkvirtualenv ENV_NAME\n\n'
113+
'# Leaving your virtual environment:\n'
114+
'deactivate\n\n'
115+
'# Returning to a virtual environment:\n'
116+
'workon ENV_NAME\n\n'
117+
'# Listing all virtual environments:\n'
118+
'lsvirtualenv # OR "workon"\n\n'
119+
'# Deleting a virtual environment:\n'
120+
'rmvirtualenv ENV_NAME'))
121+
self.add_slide(
122+
'<p><b>Determining if you are in a virtual env</b></p>'
123+
'<hr /><br />'
124+
'<p>When activated, the name of your virtual env'
125+
' will appear in parentheses on the left side of your'
126+
' command prompt.</p>',
127+
code=(
128+
'# Example of how it may look on a Windows machine:\n'
129+
'C:\\Users\\Michael\\github> mkvirtualenv my_env\n'
130+
'(my_env) C:\\Users\\Michael\\github>'))
131+
self.add_slide(
132+
'<p><b>Installing packages with "pip install"</b></p><hr /><br />'
133+
'<p>Once you have created a Python virtual environment and are'
134+
' inside, it is now safe to install packages from PyPI,'
135+
' setup.py files, and/or requirements.txt files.</p>\n',
136+
code=(
137+
'# Install a package from PyPI:\n'
138+
'pip install seleniumbase\n\n'
139+
'# Install packages from a folder with setup.py:\n'
140+
'pip install . # Normal installation\n'
141+
'pip install -e . # Editable install\n\n'
142+
'# Install packages from a requirements.txt file:\n'
143+
'pip install -r requirements.txt\n'))
144+
self.add_slide(
145+
'<p><b>Other useful "pip" commands</b></p><hr /><br />',
146+
code=(
147+
'# See which Python packages are installed:\n'
148+
'pip list\n\n'
149+
'# See which installed Python packages are outdated:\n'
150+
'pip list --outdated\n\n'
151+
'# Create a requirements file from installed packages:\n'
152+
'pip freeze > my_requirements.txt'))
153+
self.add_slide(
154+
'<br /><br /><h2><b>Live Demo Time!</b></h2><hr /><br />',
155+
image="https://seleniumbase.io/other/python_3d_logo.png")
156+
self.add_slide(
157+
'<h2><b>The End. Questions?</b></h2><hr /><br />\n'
158+
'<h3>Where to find me:</h3>'
159+
'<ul>'
160+
'<li><a href="https://github.com/mdmintz">'
161+
'https://github.com/mdmintz</a></li>'
162+
'<li><a href="https://github.com/seleniumbase/SeleniumBase">'
163+
'https://github.com/seleniumbase/SeleniumBase</a></li>'
164+
'<li><a href="https://seleniumbase.io/">'
165+
'https://seleniumbase.io/</a></li>'
166+
'</ul>')
167+
self.begin_presentation(
168+
filename="py_virtual_envs.html", show_notes=False, interval=0)

help_docs/customizing_test_runs.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,16 @@ Here are some examples of configuring tests, which can be run from the [examples
88

99
```bash
1010
# Run a test in Chrome (default browser)
11-
pytest test_swag_labs.py
11+
pytest my_first_test.py
1212

1313
# Run a test in Firefox
1414
pytest test_swag_labs.py --browser=firefox
1515

1616
# Run a test in Demo Mode (highlight assertions)
17-
pytest my_first_test.py --demo
18-
19-
# Run another test in Demo Mode
2017
pytest test_demo_site.py --demo
2118

2219
# Run a test in Headless Mode (invisible browser)
23-
pytest my_first_test.py --headless
20+
pytest test_demo_site.py --headless
2421

2522
# Run tests multi-threaded using [n] threads
2623
pytest test_suite.py -n=4
@@ -108,7 +105,7 @@ SeleniumBase provides additional ``pytest`` command-line options for tests:
108105
--proxy=SERVER:PORT # (Connect to a proxy server:port for tests.)
109106
--proxy=USERNAME:PASSWORD@SERVER:PORT # (Use authenticated proxy server.)
110107
--mobile # (Use the mobile device emulator while running tests.)
111-
--metrics=STRING # (Set mobile "CSSWidth,CSSHeight,PixelRatio".)
108+
--metrics=STRING # (Set mobile metrics: "CSSWidth,CSSHeight,PixelRatio".)
112109
--extension-zip=ZIP # (Load a Chrome Extension .zip|.crx, comma-separated.)
113110
--extension-dir=DIR # (Load a Chrome Extension directory, comma-separated.)
114111
--headless # (Run tests headlessly. Default mode on Linux OS.)

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.50.6"
2+
__version__ = "1.50.7"

seleniumbase/core/browser_launcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ def _create_firefox_profile(
310310
profile.set_preference("app.update.silent", True)
311311
profile.set_preference("browser.formfill.enable", False)
312312
profile.set_preference("browser.privatebrowsing.autostart", True)
313-
profile.set_preference("devtools.errorconsole.enabled", False)
313+
profile.set_preference("devtools.errorconsole.enabled", True)
314314
profile.set_preference("dom.webnotifications.enabled", False)
315-
profile.set_preference("dom.disable_beforeunload", False)
315+
profile.set_preference("dom.disable_beforeunload", True)
316316
profile.set_preference("browser.contentblocking.database.enabled", False)
317317
profile.set_preference("extensions.allowPrivateBrowsingByDefault", True)
318318
profile.set_preference("extensions.PrivateBrowsing.notification", False)

seleniumbase/fixtures/base_case.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3515,9 +3515,9 @@ def create_presentation(
35153515
'<link rel="stylesheet" href="%s">\n'
35163516
'<style>\n'
35173517
'pre{background-color:#fbe8d4;border-radius:8px;}\n'
3518-
'div[flex_div]{height:75vh;margin:0;align-items:center;'
3518+
'div[flex_div]{height:68vh;margin:0;align-items:center;'
35193519
'justify-content:center;}\n'
3520-
'img[rounded]{border-radius:16px;max-width:82%%;}\n'
3520+
'img[rounded]{border-radius:16px;max-width:64%%;}\n'
35213521
'</style>\n'
35223522
'</head>\n\n'
35233523
'<body>\n'
@@ -3578,7 +3578,7 @@ def add_slide(self, content=None, image=None, code=None, iframe=None,
35783578
'\n<section data-transition="%s">%s%s' % (
35793579
transition, add_line, content))
35803580
if image:
3581-
html += '\n<div flex_div><img rounded src="%s"></div>' % image
3581+
html += '\n<div flex_div><img rounded src="%s" /></div>' % image
35823582
if code:
35833583
html += '\n<div></div>'
35843584
html += '\n<pre class="prettyprint">\n%s</pre>' % code
@@ -3640,7 +3640,7 @@ def save_presentation(
36403640
'<script src="%s"></script>\n'
36413641
'<script src="%s"></script>\n'
36423642
'<script>Reveal.initialize('
3643-
'{showNotes: %s, slideNumber: true, '
3643+
'{showNotes: %s, slideNumber: true, hash: false, '
36443644
'autoSlide: %s,});'
36453645
'</script>\n'
36463646
'</body>\n'

seleniumbase/plugins/pytest_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def pytest_addoption(parser):
2929
--proxy=USERNAME:PASSWORD@SERVER:PORT (Use authenticated proxy server.)
3030
--agent=STRING (Modify the web browser's User-Agent string.)
3131
--mobile (Use the mobile device emulator while running tests.)
32-
--metrics=STRING (Set mobile "CSSWidth,CSSHeight,PixelRatio".)
32+
--metrics=STRING (Set mobile metrics: "CSSWidth,CSSHeight,PixelRatio".)
3333
--extension-zip=ZIP (Load a Chrome Extension .zip|.crx, comma-separated.)
3434
--extension-dir=DIR (Load a Chrome Extension directory, comma-separated.)
3535
--headless (Run tests headlessly. Default mode on Linux OS.)

0 commit comments

Comments
 (0)