From 1fdde97d8db15e309e217d516acf2a679d322671 Mon Sep 17 00:00:00 2001
From: Michael Mintz
Date: Mon, 25 May 2020 04:26:19 -0400
Subject: [PATCH] Update the docs
---
docs/prepare.py | 2 +-
help_docs/ReadMe.md | 2 +
help_docs/features_list.md | 2 +-
help_docs/js_package_mgr.md | 92 +++++++++++++++++++++++++++++++++
mkdocs.yml | 1 +
seleniumbase/masterqa/ReadMe.md | 10 ++--
6 files changed, 102 insertions(+), 7 deletions(-)
create mode 100755 help_docs/js_package_mgr.md
diff --git a/docs/prepare.py b/docs/prepare.py
index 6cae61ca..de7069bc 100644
--- a/docs/prepare.py
+++ b/docs/prepare.py
@@ -100,7 +100,7 @@ def main(*args, **kwargs):
r''
r''
+ r'-02A79E.svg" alt="SeleniumBase on GitHub" />'
r'
')
if "" in line:
changed = True
diff --git a/help_docs/ReadMe.md b/help_docs/ReadMe.md
index 589645a6..e11426cf 100755
--- a/help_docs/ReadMe.md
+++ b/help_docs/ReadMe.md
@@ -17,6 +17,7 @@
+
@@ -42,6 +43,7 @@
+
diff --git a/help_docs/features_list.md b/help_docs/features_list.md
index 212283f5..58da4bc6 100755
--- a/help_docs/features_list.md
+++ b/help_docs/features_list.md
@@ -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``)
diff --git a/help_docs/js_package_mgr.md b/help_docs/js_package_mgr.md
new file mode 100755
index 00000000..7f22cd32
--- /dev/null
+++ b/help_docs/js_package_mgr.md
@@ -0,0 +1,92 @@
+
+
+## JS Package Manager
+
+The SeleniumBase JS Package Manager lets you load any JavaScript library into any website from automation scripts.
+ Here's an example of website-tour libraries loaded into a browser session while visiting Google:
+
+
+
+This example from [google_tour.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/google_tour.py) can be run with pytest 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
+```
+
+Website tours are just one way of demonstrating the abilities of the SeleniumBase JS Package Manager.
+Here's the SeleniumBase code for loading any JS package into any website from your web browser:
+
+```python
+self.add_js_link(js_link)
+```
+
+Here's code that loads the IntroJS JavaScript library:
+
+```python
+self.add_js_link("https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.9.3/intro.min.js")
+```
+
+You can load any JS library into a web browser this way as long as you know the URL to it!
+
+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)
+```
+
+Now that you've loaded the JavaScript into the browser, you may also want to load some CSS to go along with it:
+
+```python
+self.add_css_link(css_link)
+```
+
+Here's code that loads the IntroJS CSS:
+
+```python
+self.add_css_link("https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.9.3/introjs.css")
+```
+
+And here's the Python WebDriver code that makes this possible:
+
+```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)
+```
+
+--------
+
+To learn more about SeleniumBase, check out the Docs Site:
+
+
+
+All the code is on GitHub:
+
+
+
+And if you're just interested in creating website tours with SeleniumBase, here's the link to the Website Tours ReadMe on GitHub.
diff --git a/mkdocs.yml b/mkdocs.yml
index 04ee8a2f..0aa71689 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -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:
diff --git a/seleniumbase/masterqa/ReadMe.md b/seleniumbase/masterqa/ReadMe.md
index 214fe483..9f73ff61 100755
--- a/seleniumbase/masterqa/ReadMe.md
+++ b/seleniumbase/masterqa/ReadMe.md
@@ -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``.