Update examples

This commit is contained in:
Michael Mintz 2020-12-18 01:25:31 -05:00
parent ac28e5abec
commit a719eebc71
13 changed files with 60 additions and 31 deletions

View File

@ -1,6 +1,6 @@
<img src="https://seleniumbase.io/cdn/img/super_logo_sb.png" title="SeleniumBase" width="300" />
<h2><img src="https://seleniumbase.io/img/logo3a.png" title="SeleniumBase" width="32" /> Running Example Tests:</h2>
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Running Example Tests:</h2>
<p align="left"><a align="center" href="https://github.com/seleniumbase/SeleniumBase/blob/master/README.md"><img align="center" src="https://seleniumbase.io/cdn/img/sb_demo_page.png" alt="SeleniumBase" width="420" /></a></p>
@ -12,7 +12,7 @@
(NOTE: Some example tests fail on purpose to demonstrate [logging features](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md).)
<h3><img src="https://seleniumbase.io/img/logo3a.png" title="SeleniumBase" width="32" /> Example run commands to help you get started:</h3>
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Example run commands to help you get started:</h3>
Run an example test in Chrome: (Default: ``--browser=chrome``)

View File

@ -1,4 +1,4 @@
<h3 align="left"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" width="290" /></h3>
<h3 align="left"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" width="360" /></h3>
<h3> 📊 ChartMaker 📈 </h3>

View File

@ -3,7 +3,7 @@ from seleniumbase import BaseCase
class MyChartMakerClass(BaseCase):
def test_chart_maker(self):
def test_area_chart(self):
self.create_presentation(theme="moon")
self.create_area_chart(
title="Time Outside", subtitle="Last Week", unit="Minutes")

View File

@ -3,7 +3,7 @@ from seleniumbase import BaseCase
class MyChartMakerClass(BaseCase):
def test_chart_maker(self):
def test_line_chart(self):
self.create_presentation()
self.create_line_chart(
title="Time Outside", subtitle="Last Week", unit="Minutes")

View File

@ -3,7 +3,7 @@ from seleniumbase import BaseCase
class MyChartMakerClass(BaseCase):
def test_multi_series_chart(self):
def test_multi_series(self):
self.create_presentation(theme="league")
self.create_line_chart(

View File

@ -9,7 +9,7 @@ from seleniumbase import encryption
class MyTestClass(BaseCase):
def test_rate_limited_printing(self):
def test_decrypt_password(self):
self.open("https://www.saucedemo.com/")
self.type("#user-name", "standard_user")

View File

@ -1,8 +1,8 @@
<a align="center" href="https://github.com/seleniumbase/SeleniumBase/"><img align="center" src="https://seleniumbase.io/cdn/img/super_logo_sb.png" title="SeleniumBase" width="290" /></a>
<a align="center" href="https://github.com/seleniumbase/SeleniumBase/"><img align="center" src="https://seleniumbase.io/cdn/img/super_logo_sb.png" title="SeleniumBase" width="320" /></a>
### <img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Logging, Screenshots, and Reports:
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Logging, Dashboards, and Reports:</h3>
Log files in [SeleniumBase/examples/example_logs](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/example_logs) were generated when [test_fail.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_fail.py) ran and failed. During test failures, logs and screenshots get saved to the ``latest_logs/`` folder. If ``--archive-logs`` is set, test logs will get archived to the ``archived_logs/`` folder.
Log files in [SeleniumBase/examples/example_logs](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/example_logs) were generated when [test_fail.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_fail.py) ran and failed. During test failures, logs and screenshots from the latest run will get saved to the ``latest_logs/`` folder. If ``--archive-logs`` is set, test logs will get archived to the ``archived_logs/`` folder (otherwise they will be cleaned out when the next test run begins).
```bash
pytest test_fail.py --browser=chrome
@ -17,28 +17,56 @@ nosetests test_fail.py --browser=firefox
<li><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/screenshot.png">screenshot.png</a></li>
</ul>
<b>In addition to log files, you can also generate a dashboard and test reports.</b>
--------
<b>In addition to logging, you can also generate test reports:</b>
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> The SeleniumBase Dashboard:</h3>
Reports are most useful when running large test suites. Pytest and Nosetest reports are handled differently.
The ``--dashboard`` option for pytest generates a SeleniumBase Dashboard located at ``dashboard.html``, which updates automatically as tests run and produce results.
### <img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Pytest Reports:
<img src="https://seleniumbase.io/cdn/img/dashboard_1.png" alt="The SeleniumBase Dashboard" title="The SeleniumBase Dashboard" width="360" />
Additionally, you can host your own SeleniumBase Dashboard Server on a port of your choice. Here's an example of that using Python 3's ``http.server``:
```bash
python -m http.server 1948
```
Now you can navigate to ``http://localhost:1948/dashboard.html`` in order to view the served dashboard from a web browser. (Be sure to run that command in the same directory where you ran your tests.)
Here's a full example of what the SeleniumBase Dashboard may look like:
```bash
pytest test_suite.py --dashboard --rs --headless
```
<img src="https://seleniumbase.io/cdn/img/dashboard_2.png" alt="The SeleniumBase Dashboard" title="The SeleniumBase Dashboard" width="480" />
--------
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Pytest Reports:</h3>
Using ``--html=report.html`` gives you a fancy report of the name specified after your test suite completes.
```bash
pytest test_suite.py --html=report.html
```
<img src="https://seleniumbase.io/cdn/img/html_report.png" alt="Example Pytest Report" title="Example Pytest Report" width="520" />
### <img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Nosetest Reports:
If viewing pytest html reports in [Jenkins](https://www.jenkins.io/), you may need to [configure Jenkins settings](https://stackoverflow.com/a/46197356) for the html to render correctly. This is due to [Jenkins CSP changes](https://www.jenkins.io/doc/book/system-administration/security/configuring-content-security-policy/).
--------
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Nosetest Reports:</h3>
The ``--report`` option gives you a fancy report after your test suite completes.
```bash
nosetests test_suite.py --report --browser=chrome
```
<img src="https://seleniumbase.io/cdn/img/nose_report.png" alt="Example Nosetest Report" title="Example Nosetest Report" width="320" />
(NOTE: You can add ``--show-report`` to immediately display Nosetest reports after the test suite completes. Only use ``--show-report`` when running tests locally because it pauses the test run.)

View File

@ -14,11 +14,10 @@ class GitHubTests(BaseCase):
if self.headless and (
self.browser == "chrome" or self.browser == "edge"):
self.get_new_driver(
agent="""Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) """
agent="""Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) """
"""AppleWebKit/537.36 (KHTML, like Gecko) """
"""Chrome/75.0.3770.100 Safari/537.36""")
self.open("https://github.com/")
self.type("input.header-search-input", "SeleniumBase\n")
"""Chrome/86.0.4240.198 Safari/537.36""")
self.open("https://github.com/search?q=SeleniumBase")
self.slow_click('a[href="/seleniumbase/SeleniumBase"]')
self.click_if_visible('[data-action="click:signup-prompt#dismiss"]')
self.assert_element("div.repository-content")

View File

@ -1,4 +1,4 @@
<h3 align="left"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" width="290" /></h3>
<h3 align="left"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" width="360" /></h3>
<h1> 📰 Presenter 📑 </h1>

View File

@ -110,9 +110,9 @@ class PythonVirtualEnvPresentation(BaseCase):
code=(
'# Create a virtual environment:\n'
'mkvirtualenv ENV_NAME\n\n'
'# Leave your virtual environment:\n'
'# Exit your virtual environment:\n'
'deactivate\n\n'
'# Return to a virtual environment:\n'
'# Re-enter a virtual environment:\n'
'workon ENV_NAME\n\n'
'# List all virtual environments:\n'
'workon\n\n'
@ -158,11 +158,11 @@ class PythonVirtualEnvPresentation(BaseCase):
'<h3>Where to find me:</h3>'
'<ul>'
'<li><a href="https://github.com/mdmintz">'
'https://github.com/mdmintz</a></li>'
'github.com/mdmintz</a></li>'
'<li><a href="https://github.com/seleniumbase/SeleniumBase">'
'https://github.com/seleniumbase/SeleniumBase</a></li>'
'github.com/seleniumbase/SeleniumBase</a></li>'
'<li><a href="https://seleniumbase.io/">'
'https://seleniumbase.io/</a></li>'
'seleniumbase.io</a></li>'
'</ul>')
self.begin_presentation(
filename="py_virtual_envs.html", show_notes=False, interval=0)

View File

@ -3,17 +3,19 @@ This test demonstrates the use of the "rate_limited" decorator.
You can use this decorator on any method to rate-limit it.
"""
import unittest
from seleniumbase import BaseCase
from seleniumbase import decorators
class MyTestClass(unittest.TestCase):
class MyTestClass(BaseCase):
@decorators.rate_limited(3.5) # The arg is max calls per second
@decorators.rate_limited(4.2) # The arg is max calls per second
def print_item(self, item):
print(item)
def test_rate_limited_printing(self):
print("\nRunning rate-limited print test:")
message = "Running rate-limited print() on the command line"
self.open("data:text/html,<p>%s</p>" % message)
print("\n%s:" % message)
for item in range(1, 11):
self.print_item(item)

View File

@ -11,9 +11,9 @@ class AppleTestClass(BaseCase):
if self.headless and (
self.browser == "chrome" or self.browser == "edge"):
self.get_new_driver(
agent="""Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) """
agent="""Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) """
"""AppleWebKit/537.36 (KHTML, like Gecko) """
"""Chrome/75.0.3770.100 Safari/537.36""")
"""Chrome/86.0.4240.198 Safari/537.36""")
self.open("https://developer.apple.com/search/")
title = "Testing with WebDriver in Safari"
self.type('[placeholder*="developer.apple.com"]', title + "\n")

View File

@ -1,4 +1,4 @@
<h3 align="left"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" width="290" /></h3>
<h3 align="left"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" width="360" /></h3>
## Website Tours