Skip to content

Commit 1fdde97

Browse files
committed
Update the docs
1 parent cc6cb64 commit 1fdde97

File tree

6 files changed

+102
-7
lines changed

6 files changed

+102
-7
lines changed

docs/prepare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def main(*args, **kwargs):
100100
r'<a href="https://github.com/seleniumbase/SeleniumBase">'
101101
r'<img src="https://img.shields.io/badge/'
102102
r'✅%20💛%20View%20Code-on%20GitHub%20🌎%20🚀'
103-
r'-02A79E.svg" alt="SeleniumBase.io Docs" />'
103+
r'-02A79E.svg" alt="SeleniumBase on GitHub" />'
104104
r'</a></div></p>')
105105
if "<!-- SeleniumBase Header -->" in line:
106106
changed = True

help_docs/ReadMe.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<div><a href="https://seleniumbase.io/help_docs/mobile_testing/"><b>Mobile Device Testing</b></a></div>
1818
<div><a href="https://seleniumbase.io/help_docs/method_summary/"><b>Method Summary (API Ref)</b></a></div>
1919
<div><a href="https://seleniumbase.io/help_docs/translations/"><b>Language Translations</b></a></div>
20+
<div><a href="https://seleniumbase.io/help_docs/js_package_mgr/"><b>JS Package Manager</b></a></div>
2021
<div><a href="https://seleniumbase.io/examples/tour_examples/ReadMe/"><b>Tour Examples</b></a></div>
2122
<div><a href="https://seleniumbase.io/help_docs/mysql_installation/"><b>MySQL Installation Overview</b></a></div>
2223
<div><a href="https://seleniumbase.io/seleniumbase/utilities/selenium_grid/ReadMe/"><b>Using the Selenium Grid</b></a></div>
@@ -42,6 +43,7 @@
4243
<div><a href="https://seleniumbase.com/help_docs/mobile_testing.html"><b>Mobile Device Testing</b></a></div>
4344
<div><a href="https://seleniumbase.com/help_docs/method_summary.html"><b>Method Summary (API Ref)</b></a></div>
4445
<div><a href="https://seleniumbase.com/help_docs/translations.html"><b>Language Translations</b></a></div>
46+
<div><a href="https://seleniumbase.com/help_docs/js_package_mgr.html"><b>JS Package Manager</b></a></div>
4547
<div><a href="https://seleniumbase.com/examples/tour_examples/"><b>Tour Examples</b></a></div>
4648
<div><a href="https://seleniumbase.com/help_docs/mysql_installation.html"><b>MySQL Installation Overview</b></a></div>
4749
<div><a href="https://seleniumbase.com/seleniumbase/utilities/selenium_grid/"><b>Using the Selenium Grid</b></a></div>

help_docs/features_list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* A complete test automation framework for web/mobile UI testing.
1010
* 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.
1111
* No more flaky tests! (Smart-waiting code keeps tests reliable.)
12-
* Includes powerful [console scripts](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md). Type **``seleniumbase``** to activate.
12+
* Powerful [console scripts](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md). (Type **``seleniumbase``** or **``sbase``** to use.)
1313
* Has the ability to translate tests into [multiple spoken languages](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/translations).
1414
* Has a flexible [command-line interface](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md) for customizing test runs.
1515
* Can run tests multithreaded in parallel. (Use ``-n NUM_THREADS``)

help_docs/js_package_mgr.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<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>
2+
3+
## JS Package Manager
4+
5+
<p>The SeleniumBase JS Package Manager lets you load any JavaScript library into any website from automation scripts.</p>
6+
<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:
7+
8+
<img src="https://cdn2.hubspot.net/hubfs/100006/google_tour_3.gif" title="SeleniumBase Tour of Google"><br />
9+
10+
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):
11+
12+
```bash
13+
pytest google_tour.py
14+
```
15+
16+
<div>Website tours are just one way of demonstrating the abilities of the SeleniumBase JS Package Manager.</div>
17+
<div>Here's the SeleniumBase code for loading any JS package into any website from your web browser:</div>
18+
19+
```python
20+
self.add_js_link(js_link)
21+
```
22+
23+
Here's code that loads the <a href="https://introjs.com/">IntroJS</a> JavaScript library:
24+
25+
```python
26+
self.add_js_link("https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.9.3/intro.min.js")
27+
```
28+
29+
<div>You can load any JS library into a web browser this way as long as you know the URL to it!</div>
30+
31+
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:
32+
33+
```python
34+
def add_js_link(driver, js_link):
35+
script_to_add_js = (
36+
"""function injectJS(link) {
37+
var body = document.getElementsByTagName("body")[0];
38+
var script = document.createElement("script");
39+
script.src = link;
40+
script.defer;
41+
script.type="text/javascript";
42+
script.crossorigin = "anonymous";
43+
script.onload = function() { null };
44+
body.appendChild(script);
45+
}
46+
injectJS("%s");""")
47+
js_link = escape_quotes_if_needed(js_link)
48+
driver.execute_script(script_to_add_js % js_link)
49+
```
50+
51+
<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>
52+
53+
```python
54+
self.add_css_link(css_link)
55+
```
56+
57+
<p>Here's code that loads the <a href="https://introjs.com/">IntroJS</a> CSS:</p>
58+
59+
```python
60+
self.add_css_link("https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.9.3/introjs.css")
61+
```
62+
63+
<p>And here's the Python WebDriver code that makes this possible:</p>
64+
65+
```python
66+
def add_css_link(driver, css_link):
67+
script_to_add_css = (
68+
"""function injectCSS(css) {
69+
var head = document.getElementsByTagName("head")[0];
70+
var link = document.createElement("link");
71+
link.rel = "stylesheet";
72+
link.type = "text/css";
73+
link.href = css;
74+
link.crossorigin = "anonymous";
75+
head.appendChild(link);
76+
}
77+
injectCSS("%s");""")
78+
css_link = escape_quotes_if_needed(css_link)
79+
driver.execute_script(script_to_add_css % css_link)
80+
```
81+
82+
--------
83+
84+
<div>To learn more about SeleniumBase, check out the Docs Site:</div>
85+
<a href="https://seleniumbase.io">
86+
<img src="https://img.shields.io/badge/docs-%20%20SeleniumBase.io-11BBDD.svg" alt="SeleniumBase.io Docs" /></a>
87+
88+
<div>All the code is on GitHub:</div>
89+
<a href="https://github.com/seleniumbase/SeleniumBase">
90+
<img src="https://img.shields.io/badge/✅%20💛%20View%20Code-on%20GitHub%20🌎%20🚀-02A79E.svg" alt="SeleniumBase on GitHub" /></a>
91+
92+
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>.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ nav:
6969
- API Reference: help_docs/method_summary.md
7070
- Mobile Testing: help_docs/mobile_testing.md
7171
- Console Scripts: seleniumbase/console_scripts/ReadMe.md
72+
- JS Package Manager: help_docs/js_package_mgr.md
7273
- Site Tours: examples/tour_examples/ReadMe.md
7374
- Visual Testing: examples/visual_testing/ReadMe.md
7475
- Integrations:

seleniumbase/masterqa/ReadMe.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
![](https://cdn2.hubspot.net/hubfs/100006/images/masterqa6.gif "MasterQA")
66

7-
Here's example code from [basic_masterqa_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/basic_masterqa_test.py):
7+
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):
88

99
```python
1010
self.open("https://xkcd.com/1700/")
@@ -17,7 +17,7 @@ self.verify('Do you see "dragons" in the search results?')
1717

1818
After each automation checkpoint, a pop-up window will ask the user questions for each verification command.
1919

20-
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.)
20+
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.)
2121

2222
![](https://cdn2.hubspot.net/hubfs/100006/images/hybrid_screen.png "MasterQA")
2323

@@ -30,13 +30,13 @@ cd SeleniumBase
3030
pip install -r requirements.txt --upgrade
3131
python setup.py develop
3232
cd examples/master_qa
33-
pytest basic_masterqa_test.py
34-
pytest masterqa_test.py
33+
pytest basic_masterqa_test_0.py
34+
pytest masterqa_test_1.py
3535
```
3636

3737
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.
3838

39-
### 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:
39+
### 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:
4040

4141
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``.
4242

0 commit comments

Comments
 (0)