Skip to content

Commit c5f8018

Browse files
committed
Update multiple ReadMe files
1 parent 300856e commit c5f8018

File tree

5 files changed

+119
-86
lines changed

5 files changed

+119
-86
lines changed

README.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ SeleniumBase was originally built for [testing HubSpot's platform](https://produ
6363

6464
## Get Started:
6565

66-
Before installation, **[install Python](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/install_python_pip_git.md)** and **[get a WebDriver](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/webdriver_installation.md)** on your system PATH.
66+
Before installation, **[install Python](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/install_python_pip_git.md)** and **[install a web driver](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/webdriver_installation.md)**.
6767

6868

6969
### ![http://seleniumbase.com](https://cdn2.hubspot.net/hubfs/100006/images/super_logo_tiny.png "SeleniumBase") **Step 1:** Clone SeleniumBase
@@ -151,32 +151,23 @@ If the example test is moving too fast for your eyes to see what's going on, you
151151
pytest my_first_test.py --demo_mode
152152
```
153153

154-
You can override the default wait time by either updating [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) or by using ``--demo_sleep={NUM}`` when using Demo Mode. (NOTE: If you use ``--demo_sleep={NUM}`` without using ``--demo_mode``, nothing will happen.)
155-
156-
```bash
157-
pytest my_first_test.py --demo_mode --demo_sleep=1.2
158-
```
159-
160-
You can also use the following in your scripts to slow down the tests:
154+
You can use the following in your scripts to help you debug issues::
161155

162156
```python
163157
import time; time.sleep(5) # sleep for 5 seconds (add this after the line you want to pause on)
164158
import ipdb; ipdb.set_trace() # waits for your command. n = next line of current method, c = continue, s = step / next executed line (will jump)
159+
import pytest; pytest.set_trace() # similar to ipdb, but specific to pytest
165160
```
166161

167-
(NOTE: If you're using pytest instead of nosetests and you want to use ipdb in your script for debugging purposes, you'll need to add ``--capture=no`` (or ``-s``) on the command line, or use ``import pytest; pytest.set_trace()`` instead of using ipdb. More info on that [here](http://stackoverflow.com/questions/2678792/can-i-debug-with-python-debugger-when-using-py-test-somehow).)
168-
169-
You may also want to have your test sleep in other situations where you need to have your test wait for something. If you know what you're waiting for, you should be specific by using a command that waits for something specific to happen.
170-
171-
If you need to debug things on the fly (in case of errors), use this:
162+
**To pause an active test that throws an exception or error, add ``--pdb --pdb-failures -s``:**
172163

173164
```bash
174165
pytest my_first_test.py --browser=chrome --pdb --pdb-failures -s
175166
```
176167

177-
The above code (with --pdb) will leave your browser window open in case there's a failure, which is possible if the web pages from the example change the data that's displayed on the page. (ipdb commands: 'c', 's', 'n' => continue, step, next). You may need the ``-s`` in order to see all console output.
168+
The code above will leave your browser window open in case there's a failure. (ipdb commands: 'c', 's', 'n' => continue, step, next).
178169

179-
Here are some other useful nosetest arguments for appending to your run commands:
170+
Here are some other useful **nosetest**-specific arguments:
180171

181172
```bash
182173
--logging-level=INFO # Hide DEBUG messages, which can be overwhelming.
@@ -185,7 +176,7 @@ Here are some other useful nosetest arguments for appending to your run commands
185176
--with-id # If -v is also used, will number the tests for easy counting.
186177
```
187178

188-
During test failures you'll get detailed log files, which include screenshots, page source, and basic test info, which will get added to the logs folder at ``latest_logs/``. (Unless you have ARCHIVE_EXISTING_LOGS set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py), log files with be cleaned up at the start of the next test run. If the archive feature is enabled, those logs will get saved to the ``archived_logs/`` folder.) The ``my_test_suite.py`` collection contains tests that fail on purpose so that you can see how logging works.
179+
During test failures, logs and screenshots from the most recent test run will get saved to the ``latest_logs/`` folder. Those logs will get moved to ``archived_logs/`` if you have ARCHIVE_EXISTING_LOGS set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py), otherwise log files with be cleaned up at the start of the next test run. The ``my_test_suite.py`` collection contains tests that fail on purpose so that you can see how logging works.
189180

190181
```bash
191182
cd examples/
@@ -210,7 +201,7 @@ To run Pytest multithreaded on multiple CPUs at the same time, add ``-n=NUM`` or
210201
<a id="creating_visual_reports"></a>
211202
### ![http://seleniumbase.com](https://cdn2.hubspot.net/hubfs/100006/images/super_logo_tiny.png "SeleniumBase") **Creating Visual Test Suite Reports:**
212203

213-
(NOTE: The command line args are different for Pytest vs Nosetests)
204+
(NOTE: Several command line args are different for Pytest vs Nosetests)
214205

215206
#### **Pytest Reports:**
216207

console_scripts/ReadMe.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
## Console Scripts
22

3+
SeleniumBase console scripts help you get things done more easily, such as installing web drivers, creating a test directory with necessary configuration files, converting old Webdriver unittest scripts into SeleniumBase code, and using the Selenium Grid.
4+
5+
For running tests from the command line, [use **pytest** with SeleniumBase](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md).
6+
7+
### install
8+
9+
* Usage:
10+
``seleniumbase install [DRIVER_NAME]``
11+
(Drivers: chromedriver, geckodriver, edgedriver)
12+
13+
* Example:
14+
``seleniumbase install chromedriver``
15+
16+
* Output:
17+
Installs the specified webdriver.
18+
(chromedriver is required for Google Chrome automation)
19+
(geckodriver is required for Mozilla Firefox automation)
20+
(edgedriver is required for Microsoft Edge automation)
21+
322
### mkdir
423

524
* Usage:
625
``seleniumbase mkdir [DIRECTORY_NAME]``
726

27+
* Example:
28+
``seleniumbase mkdir gui_tests``
29+
830
* Output:
931
Creates a new folder for running SeleniumBase scripts.
1032
The new folder contains default config files,
@@ -15,7 +37,7 @@ test frameworks.
1537
### convert
1638

1739
* Usage:
18-
``seleniumbase convert [MY_TEST.py]``
40+
``seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE]``
1941

2042
* Output:
2143
Converts a Selenium IDE exported WebDriver unittest

examples/ReadMe.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
## Running SeleniumBase Scripts
22

3-
(NOTE: If you didn't install SeleniumBase properly, these scripts won't work. Installation steps include ``pip install seleniumbase`` OR ``pip install -r requirements.txt`` + ``python setup.py develop``" from the top-level directory.)
3+
To run tests, make sure you've already installed SeleniumBase using ``pip install seleniumbase`` OR ``pip install -r requirements.txt`` + ``python setup.py develop`` from the top-level directory.
44

5-
To makes things easier, here's a simple GUI program that allows you to kick off a few example scripts by pressing a button:
6-
7-
```bash
8-
python gui_test_runner.py
9-
```
5+
You can interchange **pytest** with **nosetests**, but using pytest is strongly recommended because developers stopped supporting nosetests. Chrome is the default browser if not specified.
106

11-
(NOTE: With the exception of [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py), which should pass, many other tests in this folder fail on purpose to demonstrate features such as screenshots on failure, exception logging, and test reports.)
7+
During test failures, logs and screenshots from the most recent test run will get saved to the ``latest_logs/`` folder. Those logs will get moved to ``archived_logs/`` if you have ARCHIVE_EXISTING_LOGS set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py)
128

13-
(NOTE: You can interchange ``pytest`` with ``nosetests`` in most of these examples.)
9+
(NOTE: Many tests in this folder fail on purpose to demonstrate the built-in logging, screenshots, and reporting features.)
1410

15-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/The_GUI_Runner.png" title="GUI Test Runner" height="400">
16-
17-
When you run tests, you’ll see two folders appear: “latest_logs” and “archived_logs”. The “latest_logs” folder will contain log files from the most recent test run, but logs will only be created if the test run is failing. Afterwards, logs from the “latest_logs” folder will get pushed to the “archived_logs” folder if you have have the ``ARCHIVE_EXISTING_LOGS`` feature enabled in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py).
18-
19-
**For running scripts the usual way, here are some of the example run commands:**
11+
**Here are some example run commands to help get you started:**
2012

2113
Run the example test in Chrome:
2214
```bash
@@ -28,41 +20,51 @@ Run the example test in Firefox:
2820
pytest my_first_test.py --browser=firefox
2921
```
3022

31-
Run the example test in Demo Mode (runs slower and adds highlights):
23+
Run the example test in Demo Mode (highlights page objects being acted on):
3224
```bash
3325
pytest my_first_test.py --browser=chrome --demo_mode
3426
```
3527

36-
Run the example test suite in Chrome and generate an html report: (nosetests-only)
28+
Run the example test suite and generate an pytest report: (pytest-only)
3729
```bash
38-
nosetests my_test_suite.py --browser=chrome --report --show_report
30+
pytest basic_script.py --html=report.html
3931
```
4032

41-
Run the example test suite in Firefox and generate an html report: (nosetests-only)
33+
Run the example test suite and generate a nosetest report: (nosetests-only)
4234
```bash
43-
nosetests my_test_suite.py --browser=firefox --report --show_report
35+
nosetests my_test_suite.py --report --show_report
4436
```
4537

46-
Run a test with configuration specifed by a config file:
38+
Run a test using a nosetest configuration file: (nosetests-only)
4739
```bash
4840
nosetests my_first_test.py --config=example_config.cfg
4941
```
5042

51-
Run a test demonstrating the use of Python decorators available:
43+
Run a test demonstrating the use of SeleniumBase Python decorators available:
5244
```bash
5345
pytest rate_limiting_test.py
5446
```
5547

56-
Run a failing test with pdb mode enabled: (If a test failure occurs, test enters pdb mode)
48+
Run a failing test: (See the ``latest_logs/`` folder afterwards for logs and screenshots)
5749
```bash
58-
pytest test_fail.py --browser=chrome --pdb --pdb-failures
50+
pytest test_fail.py --browser=chrome
5951
```
6052

61-
Run a failing test (and then look into the ``latest_logs`` folder afterwards:
53+
Run a failing test with Debugging-mode enabled: (If a test failure occurs, pdb activates)
6254
```bash
63-
pytest test_fail.py --browser=chrome
55+
pytest test_fail.py --browser=chrome --pdb --pdb-failures -s
6456
```
6557

6658
For more advanced run commands, such as using a proxy server, see [../help_docs/customizing_test_runs.md](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md)
6759

60+
--------
61+
62+
To makes things easier, here's a simple GUI program that allows you to kick off a few example scripts by pressing a button:
63+
64+
```bash
65+
python gui_test_runner.py
66+
```
67+
68+
<img src="https://cdn2.hubspot.net/hubfs/100006/images/The_GUI_Runner.png" title="GUI Test Runner" height="400">
69+
6870
(NOTE: If you see any ``*.pyc`` files appear as you run tests, that's perfectly normal. Compiled bytecode is a natural result of running Python code.)

help_docs/customizing_test_runs.md

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
### Customizing test runs from the command line
1+
### Customizing test runs with **pytest** (or nosetests)
22

3-
In addition to [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py), which allows you to customize the test framework, SeleniumBase gives you the flexibility to customize & control test runs from the command line:
3+
In addition to [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) (which lets you customize SeleniumBase global properties) you can customize test runs from the command line:
44

5-
* Set the browser for tests to use (Default: Chrome)
6-
* Change the automation speed (with Demo Mode)
5+
* Choose the browser for tests to use (Default: Chrome)
76
* Choose betweeen pytest & nose unittest runners
8-
* Specify what to log and where to store logs
9-
* Choose additional variables to pass into tests
107
* Choose whether to enter Debug Mode on failures
11-
* Specify a proxy server to connect to
12-
* Choose a database to save results to
8+
* Choose additional variables to pass into tests
9+
* Change the automation speed (with Demo Mode)
10+
* Choose whether to run tests multi-threaded
1311
* Choose a Selenium Grid to connect to
12+
* Choose a database to save results to
13+
* Choose a proxy server to connect to
1414

1515
...and more!
1616

17-
**Examples:** (These are run from the **[examples](https://github.com/seleniumbase/SeleniumBase/tree/master/examples)** folder.):
17+
#### **Examples:**
18+
19+
(These are run from the **[examples](https://github.com/seleniumbase/SeleniumBase/tree/master/examples)** folder.)
1820

1921
```bash
2022
pytest my_first_test.py
@@ -25,67 +27,64 @@ pytest my_first_test.py --browser=firefox
2527

2628
pytest basic_script.py -s --pdb --pdb-failures
2729

28-
pytest my_test_suite.py --server=IP_ADDRESS -n 4
29-
3030
pytest basic_script.py --html=report.html
3131

3232
nosetests my_test_suite.py --report --show_report
3333

34+
pytest my_test_suite.py --server=IP_ADDRESS -n 4
35+
3436
pytest my_test_suite.py --proxy=IP_ADDRESS:PORT
3537
```
3638

37-
You can interchange **nosetests** with **pytest**. Chrome is the default browser if not specified. The ``-s`` option may produce additional output to make debugging easier.
39+
You can interchange **pytest** with **nosetests**, but using pytest is strongly recommended because developers stopped supporting nosetests. Chrome is the default browser if not specified.
3840

3941
(NOTE: If you're using **pytest** for running tests outside of the SeleniumBase repo, **you'll want a copy of [pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini) at the base of the new folder structure**. If using **nosetests**, the same applies for [setup.cfg](https://github.com/seleniumbase/SeleniumBase/blob/master/setup.cfg).)
4042

41-
**Example tests using Logging**:
43+
#### **Example tests using Logging:**
44+
4245
```bash
4346
pytest my_test_suite.py --browser=chrome
4447
```
45-
(NOTE: You'll automatically get full logging on test failures, which include screenshots, page source, and basic test info in the logs folder, which is ``latest_logs/`` initially, and those logs will be saved in ``archived_logs/`` if you have ARCHIVE_EXISTING_LOGS set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py))
48+
(During test failures, logs and screenshots from the most recent test run will get saved to the ``latest_logs/`` folder. Those logs will get moved to ``archived_logs/`` if you have ARCHIVE_EXISTING_LOGS set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py), otherwise log files with be cleaned up at the start of the next test run.)
4649

47-
**Demo Mode:**
50+
#### **Demo Mode:**
4851

49-
If any 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, and highlights page elements being acted on:
52+
If any 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:
5053

5154
```bash
5255
pytest my_first_test.py --browser=chrome --demo_mode
5356
```
5457

5558
You can override the default wait time by either updating [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) or by using ``--demo_sleep={NUM}`` when using Demo Mode. (NOTE: If you use ``--demo_sleep={NUM}`` without using ``--demo_mode``, nothing will happen.)
5659

57-
If you ever make any changes to your local copy of ``settings.py``, you may need to run ``python setup.py install`` for those changes to take effect.
58-
5960
```bash
6061
pytest my_first_test.py --browser=chrome --demo_mode --demo_sleep=1.2
6162
```
6263

63-
**You can also use the following in your scripts to slow down the tests:**
64+
#### **Passing additional data to tests:**
65+
66+
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.
67+
68+
#### **Running tests multithreaded:**
69+
70+
To run Pytest multithreaded on multiple CPUs at the same time, add ``-n=NUM`` or ``-n NUM`` on the command line, where NUM is the number of CPUs you want to use.
71+
72+
#### **Debugging tests:**
73+
74+
**You can use the following code snippets in your scripts to help you debug issues:**
6475
```python
6576
import time; time.sleep(5) # sleep for 5 seconds (add this after the line you want to pause on)
6677
import ipdb; ipdb.set_trace() # waits for your command. n = next line of current method, c = continue, s = step / next executed line (will jump)
78+
import pytest; pytest.set_trace() # similar to ipdb, but specific to pytest
6779
```
6880

69-
(NOTE: If you're using pytest instead of nosetests and you want to use ipdb in your script for debugging purposes, you'll either need to add ``--capture=no`` on the command line, or use ``import pytest; pytest.set_trace()`` instead of using ipdb. More info on that [here](http://stackoverflow.com/questions/2678792/can-i-debug-with-python-debugger-when-using-py-test-somehow).)
70-
71-
You may also want to have your test sleep in other situations where you need to have your test wait for something. If you know what you're waiting for, you should be specific by using a command that waits for something specific to happen.
72-
73-
**If you need to debug things on the fly (in case of errors), use this:**
81+
**To pause an active test that throws an exception or error, add ``--pdb --pdb-failures -s``:**
7482

7583
```bash
7684
pytest my_first_test.py --browser=chrome --pdb --pdb-failures -s
7785
```
7886

79-
The above code (with --pdb) will leave your browser window open in case there's a failure, which is possible if the web pages from the example change the data that's displayed on the page. (ipdb commands: 'c', 's', 'n' => continue, step, next). You may need the ``-s`` in order to see all console output.
80-
81-
**Here are some other useful nosetest arguments for appending to your run commands:**
82-
83-
```bash
84-
--logging-level=INFO # Hide DEBUG messages, which can be overwhelming.
85-
-x # Stop running the tests after the first failure is reached.
86-
-v # Prints the full test name rather than a dot for each test.
87-
--with-id # If -v is also used, will number the tests for easy counting.
88-
```
87+
The code above will leave your browser window open in case there's a failure. (ipdb commands: 'c', 's', 'n' => continue, step, next).
8988

9089
#### **Pytest Reports:**
9190

@@ -107,6 +106,15 @@ nosetests my_test_suite.py --report
107106

108107
(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.)
109108

109+
Here are some other useful **nosetest**-specific arguments:
110+
111+
```bash
112+
--logging-level=INFO # Hide DEBUG messages, which can be overwhelming.
113+
-x # Stop running the tests after the first failure is reached.
114+
-v # Prints the full test name rather than a dot for each test.
115+
--with-id # If -v is also used, will number the tests for easy counting.
116+
```
117+
110118
#### **Using a Proxy Server:**
111119

112120
If you wish to use a proxy server for your browser tests (Chrome and Firefox only), you can add ``--proxy=IP_ADDRESS:PORT`` as an argument on the command line.

0 commit comments

Comments
 (0)