Skip to content

Commit e95a7a3

Browse files
committed
Update the docs
1 parent 31a482c commit e95a7a3

File tree

4 files changed

+76
-195
lines changed

4 files changed

+76
-195
lines changed

README.md

Lines changed: 62 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -12,195 +12,121 @@ pytest my_first_test.py --demo_mode
1212

1313
## <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Quick Start:
1414

15-
(<i>Requires [Git](https://git-scm.com/) and [Python](https://www.python.org/downloads/) [<img src="https://img.shields.io/badge/python-2.7,_3.x-22AADD.svg" alt="Python versions" />](https://www.python.org/downloads/). Optionally, you may want to use a [Python virtual environment](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md) to isolate Python dependencies between projects.</i>)
15+
(<i>Requires **[Git and Python/Pip](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/install_python_pip_git.md)** [<img src="https://img.shields.io/badge/python-2.7,_3.x-22AADD.svg" alt="Python versions" />](https://www.python.org/downloads/). Optionally, you may want to use a [Python virtual environment](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md) to isolate Python dependencies between projects.</i>)
1616

17-
#### Clone SeleniumBase from GitHub:
17+
**Make sure you're using the latest versions of Pip and Setuptools:**
1818
```
19-
git clone https://github.com/seleniumbase/SeleniumBase.git
19+
python -m pip install -U pip setuptools
2020
```
21+
* (Depending on your user permissions, you may need to add ``--user`` to the command if you're not inside a [Python virtual environment](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md), or use "[sudo](https://en.wikipedia.org/wiki/Sudo)" on a UNIX-based OS if you're getting errors during installation.)
2122

22-
#### Upgrade [pip](https://pypi.org/project/pip/) and [setuptools](https://pypi.org/project/setuptools/) to the latest versions:
23+
#### Clone SeleniumBase from GitHub:
2324
```
24-
python -m pip install -U pip setuptools
25+
git clone https://github.com/seleniumbase/SeleniumBase.git
2526
```
26-
* (Depending on your user permissions, you may need to add ``--user`` to the command if you're not inside a [Python virtual environment](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md), or use "[sudo](https://en.wikipedia.org/wiki/Sudo)" on a UNIX-based OS if you're getting errors during installation.)
27+
(<i>A Git GUI tool like [SourceTree](https://www.sourcetreeapp.com/) or [GitHub Desktop](https://desktop.github.com/) may help.</i>)
2728

2829
#### Install SeleniumBase:
30+
If installing SeleniumBase from a local clone, use:
2931
```
3032
cd SeleniumBase
31-
pip install -U -r requirements.txt
33+
pip install -r requirements.txt -U
3234
python setup.py install
3335
```
34-
* (Use ``python setup.py develop`` if configuring seleniumbase inside a virtual environment.)
35-
* (You can also get seleniumbase from the Python Package Index, [<img src="https://img.shields.io/pypi/v/seleniumbase.svg" alt="Version" />](https://pypi.python.org/pypi/seleniumbase))
36+
* (Use ``python setup.py develop`` if inside a virtual environment.)
3637

37-
#### Install a web driver to the [seleniumbase/drivers](https://github.com/seleniumbase/SeleniumBase/tree/master/seleniumbase/drivers) folder:
38+
If installing SeleniumBase from [PyPI](https://pypi.python.org/pypi/seleniumbase) [<img src="https://img.shields.io/badge/pypi-seleniumbase-22AAEE.svg" alt="pypi" />](https://pypi.python.org/pypi/seleniumbase), use:
3839
```
39-
seleniumbase install chromedriver
40+
pip install seleniumbase -U --no-cache-dir
4041
```
4142

43+
If installing SeleniumBase from GitHub, use:
44+
```
45+
pip install -e git+https://github.com/seleniumbase/SeleniumBase.git@master#egg=seleniumbase
46+
```
47+
48+
#### Download a web driver to your System Path or to the [seleniumbase/drivers](https://github.com/seleniumbase/SeleniumBase/tree/master/seleniumbase/drivers) folder:
49+
50+
SeleniumBase can download a driver to the seleniumbase/drivers folder with the ``install`` command:
51+
```
52+
seleniumbase install chromedriver
53+
```
4254
* (You need a different web driver for each web browser you want to run automation on: ``chromedriver`` for Chrome, ``edgedriver`` for Edge, ``geckodriver`` for Firefox, ``operadriver`` for Opera, and ``iedriver`` for Internet Explorer.)
4355

4456
#### Run a test on Chrome:
4557
```
4658
cd examples
4759
pytest my_first_test.py --browser=chrome
4860
```
49-
5061
* (Chrome is the default browser if not specified with ``--browser``)
5162

52-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32">
53-
54-
Check out [SeleniumBase Website Tours](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/tour_examples) (in the ``examples/tour_examples`` folder). It's great for prototyping a website onboarding experience. See the [Tours ReadMe](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md) for more details.
55-
56-
```
57-
cd tour_examples
58-
pytest google_tour.py
59-
```
63+
**Here's what [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) looks like:**
6064

61-
<img src="https://cdn2.hubspot.net/hubfs/100006/google_tour_3.gif" title="SeleniumBase Tour of Google" height="260"><br>
62-
(Above: Actual demo of [google_tour.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/google_tour.py) running on [google.com](https://google.com))
65+
```python
66+
from seleniumbase import BaseCase
6367

64-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32">
68+
class MyTestClass(BaseCase):
6569

66-
For more detailed steps on getting started, see the [**Detailed Instructions**](#seleniumbase_installation) section.
70+
def test_basic(self):
71+
self.open("https://xkcd.com/353/")
72+
self.assert_element('img[alt="Python"]')
73+
self.click('a[rel="license"]')
74+
self.assert_text("free to copy", "div center")
75+
self.open("https://xkcd.com/1481/")
76+
title = self.get_attribute("#comic img", "title")
77+
self.assert_true("86,400 seconds per day" in title)
78+
self.click("link=Blag")
79+
self.assert_text("The blag of the webcomic", "h2")
80+
self.update_text("input#s", "Robots!\n")
81+
self.assert_text("Hooray robots!", "#content")
82+
self.open("https://xkcd.com/1319/")
83+
self.assert_exact_text("Automation", "#ctitle")
84+
```
85+
(<i>By default, [CSS Selectors](https://www.w3schools.com/cssref/css_selectors.asp) are used for finding page elements.</i>)
6786

6887
## <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Learn More:
6988

70-
#### **No more repetitive WebDriver code:**<br />
71-
SeleniumBase automatically handles common WebDriver actions such as spinning up web browsers, waiting for page objects to load, saving screenshots during test failures, using a proxy server, and more. (<i>[Read about customizing test runs](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md).</i>)
72-
73-
#### **Simple Python syntax makes coding easy:**<br />
74-
75-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/my_first_test_image.png" title="SeleniumBase Python Code" height="280">
89+
#### **Automatic WebDriver abilities:**<br />
90+
SeleniumBase automatically handles common WebDriver actions such as spinning up web browsers and saving screenshots during test failures. (<i>[Read more about customizing test runs](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md).</i>)
7691

77-
(<i>By default, [CSS Selectors](https://www.w3schools.com/cssref/css_selectors.asp) are used for finding page elements.</i>)
92+
#### **Simplified code:**<br />
93+
Instead of using messy WebDriver commands such as:
94+
```python
95+
self.driver.find_element_by_css_selector("textarea").send_keys("text")
96+
```
97+
...you can do the following with SeleniumBase:
98+
```python
99+
self.update_text("textarea", "text")
100+
```
101+
(<i>You can still use ``self.driver`` in your code.</i>)
78102

79103
#### **Run tests with Pytest or Nose in any browser:**<br />
80104
(<i>Using **Pytest** is strongly recommended</i>)
81-
82105
```
83106
pytest my_first_test.py --browser=chrome
84107
85108
nosetests test_suite.py --browser=firefox
86109
```
87-
88110
Python methods that start with ``test_`` will automatically be run when using ``pytest`` or ``nosetests`` on a Python file, (<i>or on folders containing Python files</i>).
89111

90-
#### **No more messy code:**<br />
91-
This long line of standard WebDriver code,
92-
```python
93-
self.driver.find_element_by_css_selector("textarea").send_keys("text")
94-
```
95-
...becomes the following in SeleniumBase:
96-
```python
97-
self.update_text("textarea", "text")
98-
```
99-
(<i>You can still use ``self.driver`` in your code.</i>)
100-
101112
#### **No more flaky tests:**<br />
102-
SeleniumBase methods automatically wait for page elements to finish loading before interacting with them (*up to a timeout limit*). This means you no longer need random ``time.sleep()`` statements in your code.
103-
104-
#### **Assist manual QA with automation:**<br />
105-
SeleniumBase includes an automated/manual hybrid solution called **[MasterQA](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/masterqa/ReadMe.md)**, which speeds up manual testing by having automation perform all the web browser actions while the manual tester only validates what is seen.
106-
107-
#### **Integrate with your favorite tools:**<br />
108-
SeleniumBase is compatible with [Selenium Grid](https://github.com/seleniumbase/SeleniumBase/tree/master/seleniumbase/utilities/selenium_grid), [MySQL](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/core/testcase_manager.py), [Docker](https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/docker/ReadMe.md), [NodeJS](https://github.com/seleniumbase/SeleniumBase/tree/master/integrations/node_js), [Google Cloud](https://github.com/seleniumbase/SeleniumBase/tree/master/integrations/google_cloud/ReadMe.md), and [AWS](#amazon_section).
109-
110-
#### **Automate tedious business tasks:**<br />
111-
Beyond test automation, SeleniumBase is perfect for automating tedious business tasks that you would perform in a web browser.
113+
SeleniumBase methods automatically wait for page elements to finish loading before interacting with them (*up to a timeout limit*). This means you no longer need random ``time.sleep()`` statements in your scripts.
112114

113-
#### **Lots of happy users & customers:**<br />
114-
To learn about businesses using SeleniumBase, [Click Here](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/happy_customers.md).
115+
#### **Automated/manual hybrid mode:**<br />
116+
SeleniumBase includes a solution called **[MasterQA](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/masterqa/ReadMe.md)**, which speeds up manual testing by having automation perform all the browser actions while the manual tester handles validatation.
115117

116118
#### **Feature-Rich:**<br />
117-
To see a full list of SeleniumBase features, [Click Here](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/features_list.md).
119+
For a full list of SeleniumBase features, [Click Here](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/features_list.md).
120+
118121

119122
<a id="seleniumbase_installation"></a>
120123
<img src="https://cdn2.hubspot.net/hubfs/100006/images/logo_base_4b.png" title="SeleniumBase" height="100">
121124

122125
## <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Detailed Instructions:
123126

124-
Before installation, **[install Python and Git](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/install_python_pip_git.md)**.
125-
126-
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> **Step 1:** Clone SeleniumBase
127-
128-
```
129-
git clone https://github.com/seleniumbase/SeleniumBase.git
130-
```
131-
132-
(<i>A [Git](https://git-scm.com/) GUI tool like [SourceTree](https://www.sourcetreeapp.com/) may help.</i>)
133-
134-
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> **Step 2:** Create a Virtual Environment
135-
136-
(OPTIONAL) To learn how to create a Python virtual environment, [see this ReadMe](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md).
137-
138-
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> **Step 3:** Install SeleniumBase
139-
140-
If you're installing SeleniumBase from a cloned copy on your machine, use:
141-
```
142-
cd SeleniumBase
143-
144-
pip install -r requirements.txt --upgrade
145-
python setup.py install
146-
```
147-
148-
If you're installing SeleniumBase from the [Python Package Index](https://pypi.python.org/pypi/seleniumbase) [<img src="https://img.shields.io/badge/pypi-seleniumbase-22AAEE.svg" alt="pypi" />](https://pypi.python.org/pypi/seleniumbase), use:
149-
```
150-
pip install -U seleniumbase --no-cache-dir
151-
```
152-
153-
If you're installing SeleniumBase directly from GitHub, use:
154-
```
155-
pip install -e git+https://github.com/seleniumbase/SeleniumBase.git@master#egg=seleniumbase
156-
```
157-
158-
(If you encounter permission errors during installation while not using a virtual environment, you may need to add ``--user`` to your pip command. If you already have an older version of SeleniumBase installed, you may want to add ``--upgrade`` or ``-U`` to your pip command.)
159-
160-
<a id="seleniumbase_install_a_web_driver"></a>
161-
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> **Step 4:** Install a Web Driver
162-
163-
SeleniumBase requires a web driver to run automation on web browers. For that, you'll need to either download a web driver to your path, or **[install a web driver](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/webdriver_installation.md)** with the SeleniumBase ``install`` command.
164-
165-
```
166-
seleniumbase install chromedriver
167-
seleniumbase install geckodriver
168-
seleniumbase install edgedriver
169-
```
170-
171-
(``geckodriver`` is the offical name of the Firefox driver)
172-
173-
<a id="seleniumbase_basic_usage"></a>
174-
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> **Step 5:** Run the Example Script
175-
176-
**Here's what the example script, [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py), looks like:**
177-
178-
```python
179-
from seleniumbase import BaseCase
180-
181-
class MyTestClass(BaseCase):
182-
183-
def test_basic(self):
184-
self.open("https://xkcd.com/353/")
185-
self.assert_element('img[alt="Python"]')
186-
self.click('a[rel="license"]')
187-
self.assert_text("free to copy", "div center")
188-
self.open("https://xkcd.com/1481/")
189-
title = self.get_attribute("#comic img", "title")
190-
self.assert_true("86,400 seconds per day" in title)
191-
self.click("link=Blag")
192-
self.assert_text("The blag of the webcomic", "h2")
193-
self.update_text("input#s", "Robots!\n")
194-
self.assert_text("Hooray robots!", "#content")
195-
self.open("https://xkcd.com/1319/")
196-
self.assert_exact_text("Automation", "#ctitle")
197-
```
198-
(<i>By default, [CSS Selectors](https://www.w3schools.com/cssref/css_selectors.asp) are used for finding page elements.</i>)
199-
200127
**Here's how to run the example script on various web browsers:**
201128

202129
(NOTE: You can interchange **pytest** with **nosetests** at anytime.)
203-
204130
```
205131
cd examples/
206132
@@ -211,7 +137,7 @@ nosetests my_first_test.py --browser=firefox
211137
(<i>If no browser is specified, Chrome is used by default.</i>)
212138

213139
<a id="seleniumbase_demo_mode"></a>
214-
If the example test is moving too fast for your eyes to see what's going on, you can run it in **Demo Mode** by adding ``--demo_mode`` on the command line, which pauses the browser briefly between actions, highlights page elements being acted on, and lets you know what test assertions are happening in real time:
140+
If the example test is moving too fast for your eyes, you can run it in **Demo Mode** by adding ``--demo_mode`` on the command line, which pauses the browser briefly between actions, highlights page elements being acted on, and lets you know what test assertions are happening in real time:
215141

216142
```
217143
pytest my_first_test.py --demo_mode
@@ -258,30 +184,7 @@ To run Pytest multithreaded on multiple CPUs at the same time, add ``-n=NUM`` or
258184

259185
If you want to pass additional data from the command line to your tests, you can use ``--data=STRING``. Now inside your tests, you can use ``self.data`` to access that.
260186

261-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/logo_base_4b.png" title="SeleniumBase" height="100">
262-
263-
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> **Using SeleniumBase from a [PyPI](https://pypi.org/) installation:**
264-
265-
You can install SeleniumBase without cloning the repo by doing this:
266-
267-
```
268-
python -m pip install -U pip
269-
pip install -U seleniumbase --no-cache-dir
270-
```
271-
272-
You can then install webdrivers by doing this:
273-
274-
```
275-
seleniumbase install chromedriver
276-
seleniumbase install geckodriver
277-
seleniumbase install edgedriver
278-
seleniumbase install iedriver
279-
seleniumbase install operadriver
280-
```
281-
282-
(You'll need chromedriver if you want to run automation on Chrome, geckodriver if you want to run automation on Firefox, edgedriver for Microsoft Edge, etc.)
283-
284-
When creating your own test directories, keep these two things in mind:
187+
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> **Test Directory Customization:**
285188

286189
For running tests outside of the SeleniumBase repo with **Pytest**, you'll want a copy of **[pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini)** on the root folder. For running tests outside of the SeleniumBase repo with **Nosetests**, you'll want a copy of **[setup.cfg](https://github.com/seleniumbase/SeleniumBase/blob/master/setup.cfg)** on the root folder. (Subfolders should include a blank ``__init__.py`` file.)
287190

@@ -293,8 +196,6 @@ cd browser_tests
293196
pytest my_first_test.py --browser=chrome
294197
```
295198

296-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/logo_base_4b.png" title="SeleniumBase" height="100">
297-
298199
<a id="creating_visual_reports"></a>
299200
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> **Creating Visual Test Suite Reports:**
300201

examples/tour_examples/ReadMe.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
## SeleniumBase Website Tours
22

3-
SeleniumBase Tours utilize your choice of 4 different JavaScript libraries for creating & running tours, demos, and walkthroughs on any website: **[Shepherd](https://shipshapecode.github.io/shepherd/docs/welcome/)**, **[Bootstrap Tour](http://bootstraptour.com/)**, **[IntroJS](https://introjs.com/)**, and **[Hopscotch](http://linkedin.github.io/hopscotch/)**. Choose your favorite one to use!
3+
SeleniumBase Tours utilize your choice of 4 different JavaScript libraries for prototyping tours, demos, walkthroughs, and onboarding experiences on any website: **[Shepherd](https://shipshapecode.github.io/shepherd/docs/welcome/)**, **[Bootstrap Tour](http://bootstraptour.com/)**, **[IntroJS](https://introjs.com/)**, and **[Hopscotch](http://linkedin.github.io/hopscotch/)**. Choose your favorite one to use!
44

55
Example tour:
66

7+
```
8+
cd examples/tour_examples
9+
pytest google_tour.py
10+
```
11+
712
<img src="https://cdn2.hubspot.net/hubfs/100006/google_tour_3.gif" title="SeleniumBase Tour of Google" height="260"><br>
813

914

0 commit comments

Comments
 (0)