Update the docs

This commit is contained in:
Michael Mintz 2020-05-25 04:26:19 -04:00
parent cc6cb64bce
commit 1fdde97d8d
6 changed files with 102 additions and 7 deletions

View File

@ -100,7 +100,7 @@ def main(*args, **kwargs):
r'<a href="https://github.com/seleniumbase/SeleniumBase">'
r'<img src="https://img.shields.io/badge/'
r'%20💛%20View%20Code-on%20GitHub%20🌎%20🚀'
r'-02A79E.svg" alt="SeleniumBase.io Docs" />'
r'-02A79E.svg" alt="SeleniumBase on GitHub" />'
r'</a></div></p>')
if "<!-- SeleniumBase Header -->" in line:
changed = True

View File

@ -17,6 +17,7 @@
<div><a href="https://seleniumbase.io/help_docs/mobile_testing/"><b>Mobile Device Testing</b></a></div>
<div><a href="https://seleniumbase.io/help_docs/method_summary/"><b>Method Summary (API Ref)</b></a></div>
<div><a href="https://seleniumbase.io/help_docs/translations/"><b>Language Translations</b></a></div>
<div><a href="https://seleniumbase.io/help_docs/js_package_mgr/"><b>JS Package Manager</b></a></div>
<div><a href="https://seleniumbase.io/examples/tour_examples/ReadMe/"><b>Tour Examples</b></a></div>
<div><a href="https://seleniumbase.io/help_docs/mysql_installation/"><b>MySQL Installation Overview</b></a></div>
<div><a href="https://seleniumbase.io/seleniumbase/utilities/selenium_grid/ReadMe/"><b>Using the Selenium Grid</b></a></div>
@ -42,6 +43,7 @@
<div><a href="https://seleniumbase.com/help_docs/mobile_testing.html"><b>Mobile Device Testing</b></a></div>
<div><a href="https://seleniumbase.com/help_docs/method_summary.html"><b>Method Summary (API Ref)</b></a></div>
<div><a href="https://seleniumbase.com/help_docs/translations.html"><b>Language Translations</b></a></div>
<div><a href="https://seleniumbase.com/help_docs/js_package_mgr.html"><b>JS Package Manager</b></a></div>
<div><a href="https://seleniumbase.com/examples/tour_examples/"><b>Tour Examples</b></a></div>
<div><a href="https://seleniumbase.com/help_docs/mysql_installation.html"><b>MySQL Installation Overview</b></a></div>
<div><a href="https://seleniumbase.com/seleniumbase/utilities/selenium_grid/"><b>Using the Selenium Grid</b></a></div>

View File

@ -9,7 +9,7 @@
* A complete test automation framework for web/mobile UI testing.
* Uses [pytest](https://docs.pytest.org/en/latest/), [unittest](https://docs.python.org/3/library/unittest.html), and [nose](http://nose.readthedocs.io/en/latest/) for test discovery and execution.
* No more flaky tests! (Smart-waiting code keeps tests reliable.)
* Includes powerful [console scripts](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md). Type **``seleniumbase``** to activate.
* Powerful [console scripts](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md). (Type **``seleniumbase``** or **``sbase``** to use.)
* Has the ability to translate tests into [multiple spoken languages](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/translations).
* Has a flexible [command-line interface](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md) for customizing test runs.
* Can run tests multithreaded in parallel. (Use ``-n NUM_THREADS``)

92
help_docs/js_package_mgr.md Executable file
View File

@ -0,0 +1,92 @@
<p><h3 align="center"><a href="https://github.com/seleniumbase/SeleniumBase"><img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_sb23.png" alt="SeleniumBase" width="220" /></a></h3></p>
## JS Package Manager
<p>The SeleniumBase JS Package Manager lets you load any JavaScript library into any website from automation scripts.</p>
<img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Here's an example of website-tour libraries loaded into a browser session while visiting Google:
<img src="https://cdn2.hubspot.net/hubfs/100006/google_tour_3.gif" title="SeleniumBase Tour of Google"><br />
This example from [google_tour.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/google_tour.py) can be run with <b>pytest</b> from the SeleniumBase ``examples/tour_examples`` folder with the following command after you've cloned and installed [SeleniumBase from GitHub](https://github.com/seleniumbase/SeleniumBase):
```bash
pytest google_tour.py
```
<div>Website tours are just one way of demonstrating the abilities of the SeleniumBase JS Package Manager.</div>
<div>Here's the SeleniumBase code for loading any JS package into any website from your web browser:</div>
```python
self.add_js_link(js_link)
```
Here's code that loads the <a href="https://introjs.com/">IntroJS</a> JavaScript library:
```python
self.add_js_link("https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.9.3/intro.min.js")
```
<div>You can load any JS library into a web browser this way as long as you know the URL to it!</div>
If you're wondering how SeleniumBase does this, here's a sneak peak at the code, which uses WebDriver's ``execute_script()`` method to run JavaScript commands:
```python
def add_js_link(driver, js_link):
script_to_add_js = (
"""function injectJS(link) {
var body = document.getElementsByTagName("body")[0];
var script = document.createElement("script");
script.src = link;
script.defer;
script.type="text/javascript";
script.crossorigin = "anonymous";
script.onload = function() { null };
body.appendChild(script);
}
injectJS("%s");""")
js_link = escape_quotes_if_needed(js_link)
driver.execute_script(script_to_add_js % js_link)
```
<p>Now that you've loaded the JavaScript into the browser, you may also want to load some CSS to go along with it:</p>
```python
self.add_css_link(css_link)
```
<p>Here's code that loads the <a href="https://introjs.com/">IntroJS</a> CSS:</p>
```python
self.add_css_link("https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.9.3/introjs.css")
```
<p>And here's the Python WebDriver code that makes this possible:</p>
```python
def add_css_link(driver, css_link):
script_to_add_css = (
"""function injectCSS(css) {
var head = document.getElementsByTagName("head")[0];
var link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = css;
link.crossorigin = "anonymous";
head.appendChild(link);
}
injectCSS("%s");""")
css_link = escape_quotes_if_needed(css_link)
driver.execute_script(script_to_add_css % css_link)
```
--------
<div>To learn more about SeleniumBase, check out the Docs Site:</div>
<a href="https://seleniumbase.io">
<img src="https://img.shields.io/badge/docs-%20%20SeleniumBase.io-11BBDD.svg" alt="SeleniumBase.io Docs" /></a>
<div>All the code is on GitHub:</div>
<a href="https://github.com/seleniumbase/SeleniumBase">
<img src="https://img.shields.io/badge/✅%20💛%20View%20Code-on%20GitHub%20🌎%20🚀-02A79E.svg" alt="SeleniumBase on GitHub" /></a>
And if you're just interested in creating website tours with SeleniumBase, here's the link to the <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md">Website Tours ReadMe on GitHub</a>.

View File

@ -69,6 +69,7 @@ nav:
- API Reference: help_docs/method_summary.md
- Mobile Testing: help_docs/mobile_testing.md
- Console Scripts: seleniumbase/console_scripts/ReadMe.md
- JS Package Manager: help_docs/js_package_mgr.md
- Site Tours: examples/tour_examples/ReadMe.md
- Visual Testing: examples/visual_testing/ReadMe.md
- Integrations:

View File

@ -4,7 +4,7 @@
![](https://cdn2.hubspot.net/hubfs/100006/images/masterqa6.gif "MasterQA")
Here's example code from [basic_masterqa_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/basic_masterqa_test.py):
Here's example code from [basic_masterqa_test_0.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/basic_masterqa_test_0.py):
```python
self.open("https://xkcd.com/1700/")
@ -17,7 +17,7 @@ self.verify('Do you see "dragons" in the search results?')
After each automation checkpoint, a pop-up window will ask the user questions for each verification command.
When the test run completes, as seen from [this longer example](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/masterqa_test.py), you'll reach the results page that appears after answering all the verification questions. (Failed verifications generate links to screenshots and log files.)
When the test run completes, as seen from [this longer example](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/masterqa_test_1.py), you'll reach the results page that appears after answering all the verification questions. (Failed verifications generate links to screenshots and log files.)
![](https://cdn2.hubspot.net/hubfs/100006/images/hybrid_screen.png "MasterQA")
@ -30,13 +30,13 @@ cd SeleniumBase
pip install -r requirements.txt --upgrade
python setup.py develop
cd examples/master_qa
pytest basic_masterqa_test.py
pytest masterqa_test.py
pytest basic_masterqa_test_0.py
pytest masterqa_test_1.py
```
At the end of your test run, you'll receive a report with results, screenshots, and log files. Close the Results Page window when you're done.
### Check out [masterqa_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/masterqa_test.py) to learn how to write your own MasterQA tests:
### Check out [masterqa_test_1.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/masterqa_test_1.py) to learn how to write your own MasterQA tests:
You'll notice that tests are written the same way as regular [SeleniumBase](https://seleniumbase.com) tests, with the key difference being a different import: ``from seleniumbase import MasterQA`` rather than ``from seleniumbase import BaseCase``. Now your Python test class will import ``MasterQA`` instead of ``BaseCase``.