You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A reliable solution for fast & simple browser automation and testing with [WebDriver](https://docs.microsoft.com/en-us/microsoft-edge/webdriver) & [Pytest](https://github.com/pytest-dev/pytest).
6
6
7
-
#### Quick start in a few steps: (Requires [Python](https://www.python.org/downloads/) and [Git](https://git-scm.com/))
7
+
**Why SeleniumBase?** WebDriver automates browsers, but it's not a stand-alone test framework. SeleniumBase saves you time by providing you with a complete framework for end-to-end testing.
8
+
9
+
**Why Python?** Python is the [fastest growing programming language according to Stack Overflow](https://stackoverflow.blog/2017/09/06/incredible-growth-python/). Python's structure makes it optimal for scripting and quickly building things.
8
10
9
-
```bash
11
+
**Quick Start in a few steps:** (Requires [Python](https://www.python.org/downloads/), [Git](https://git-scm.com/), and an optional [Python virtual env](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md).)
SeleniumBase has a very flexible [command line interface](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md) to change how your tests run. The following will run the same test from above using Nosetests and Firefox with geckodriver(although Pytest is recommended over Nosetests):
27
+
SeleniumBase has a very flexible [command line interface](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md) to change how your tests run. The following will run the same test from above on Firefox (geckodriver) using nosetests (although pytest is recommended over nosetests):
24
28
25
-
```bash
29
+
```
26
30
seleniumbase install geckodriver
27
31
nosetests my_first_test.py --browser=firefox
28
32
```
29
33
30
34
Try out Demo Mode to see what what's being tested in real time! (Chrome is the default browser if not specified.)
(Above: Actual demo of [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) running against[xkcd.com](http://xkcd.com/353/))
41
+
(Above: Actual demo of [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) running on[xkcd.com](http://xkcd.com/353/))
38
42
39
43
There are many more examples to try out from the [SeleniumBase/examples](https://github.com/seleniumbase/SeleniumBase/blob/master/examples) directory, which you can run easily if you clone SeleniumBase.
40
44
41
45
Try out SeleniumBase Website Tours (from the ``examples/tour_examples`` folder). It's the best website onboarding experience available (and it's free too). Find the [WebSite Tours ReadMe here](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md).
(Above: Actual demo of [google_tour.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/google_tour.py) running against[google.com](https://google.com))
53
+
(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))
50
54
51
55
For more detailed steps on getting started, see the [**Detailed Instructions**](#seleniumbase_installation) section.
52
56
@@ -64,7 +68,7 @@ SeleniumBase automatically handles common WebDriver actions such as spinning up
64
68
**Run tests with Pytest or Nose in any browser:**<br />
65
69
(<i>Using **Pytest** is strongly recommended</i>)
66
70
67
-
```bash
71
+
```
68
72
pytest my_first_test.py --browser=chrome
69
73
70
74
nosetests my_test_suite.py --browser=firefox
@@ -98,11 +102,11 @@ SeleniumBase makes it easy to automate tedious business tasks. (*To learn about
98
102
**Extensively tested and made with love:**<br />
99
103
SeleniumBase was originally built for [testing HubSpot's platform](https://product.hubspot.com/blog/bid/88880/Automated-Integration-Testing-with-Selenium-at-HubSpot) and automating business processes. In 2014, SeleniumBase was open-sourced and spun off as its own independent entity to benefit users everywhere.
100
104
101
-
**Plenty of features:**<br />
105
+
**Feature-Rich:**<br />
102
106
([Read more about SeleniumBase features here](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/features_list.md))
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:
192
196
193
-
```bash
197
+
```
194
198
pytest my_first_test.py --demo_mode
195
199
```
196
200
@@ -204,15 +208,15 @@ import pytest; pytest.set_trace() # similar to ipdb, but specific to pytest
204
208
205
209
**To pause an active test that throws an exception or error, add ``--pdb --pdb-failures -s``:**
The code above will leave your browser window open in case there's a failure. (ipdb commands: 'c', 's', 'n' => continue, step, next).
212
216
213
217
Here are some other useful **nosetest**-specific arguments:
214
218
215
-
```bash
219
+
```
216
220
--logging-level=INFO # Hide DEBUG messages, which can be overwhelming.
217
221
-x # Stop running the tests after the first failure is reached.
218
222
-v # Prints the full test name rather than a dot for each test.
@@ -221,7 +225,7 @@ Here are some other useful **nosetest**-specific arguments:
221
225
222
226
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.
223
227
224
-
```bash
228
+
```
225
229
cd examples/
226
230
227
231
pytest my_test_suite.py --browser=chrome
@@ -241,16 +245,17 @@ If you want to pass additional data from the command line to your tests, you can
241
245
242
246
You can install SeleniumBase without cloning the repo by doing this:
243
247
244
-
```bash
248
+
```
245
249
python -m pip install -U pip
246
250
pip install -U seleniumbase --no-cache-dir
247
251
```
248
252
249
253
Now you can install webdrivers by doing this:
250
254
251
-
```bash
255
+
```
252
256
seleniumbase install chromedriver
253
257
seleniumbase install geckodriver
258
+
seleniumbase install edgedriver
254
259
```
255
260
256
261
Remember, 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.
@@ -265,7 +270,7 @@ For running tests outside of the SeleniumBase repo with **Nosetests**, you'll wa
265
270
266
271
As a shortcut, you'll be able to run ``seleniumbase mkdir [DIRECTORY_NAME]`` to create a new folder that already contains necessary files and some example tests that you can run. Example:
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.
312
317
313
-
```bash
318
+
```
314
319
pytest proxy_test.py --proxy=IP_ADDRESS:PORT
315
320
```
316
321
317
322
To make things easier, you can add your frequently-used proxies to PROXY_LIST in [proxy_list.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/proxy_list.py), and then use ``--proxy=KEY_FROM_PROXY_LIST`` to use the IP_ADDRESS:PORT of that key.
318
323
319
-
```bash
324
+
```
320
325
pytest proxy_test.py --proxy=proxy1
321
326
```
322
327
@@ -331,7 +336,7 @@ Here are some things you can do to setup a production environment for your testi
331
336
332
337
* If you're using the [SeleniumBase MySQL feature](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/mysql_installation.md) to save results from tests running on a server machine, you can install [MySQL Workbench](http://dev.mysql.com/downloads/tools/workbench/) to help you read & write from your DB more easily. You'll also need to install the MySQL Python client. Depending on your system, you may need to install additional requirements for this (such as on Windows). See [Stackoverflow](https://stackoverflow.com/questions/43102442/whats-the-difference-between-mysqldb-mysqlclient-and-mysql-connector-python) for more info.
* If you're using AWS, you can setup an [Amazon S3](http://aws.amazon.com/s3/) account for saving your log files and screenshots for future viewing. SeleniumBase already has [all the code you need to connect to S3](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/plugins/s3_logging_plugin.py). You'll need to modify [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) with connection details to your instance and the location in S3 where you want log files to be saved. You'll also need to add "``--with-s3_logging``" on the command line when you run your tests.
342
347
343
348
Here's an example of running tests with additional features enabled:
(NOTE: If you haven't configured your MySQL or S3 connections in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py), don't use ``--with-db_reporting`` or ``--with-s3_logging``.)
@@ -350,15 +355,15 @@ When the testing_base plugin is used, if there's a test failure, the basic_test_
350
355
351
356
To simplify that long run command, you can create a *.cfg file, such as the one provided in the example, and enter your plugins there so that you can run everything by typing:
You can simplify that even more by using a setup.cfg file, such as the one provided for you in the examples folder. If you kick off a test run from within the folder that setup.cfg is location in, that file will automatically be used as your configuration, meaning that you wouldn't have to type out all the plugins that you want to use (or include a config file) everytime you run tests.
358
363
359
364
If you tell pytest/nosetests to run an entire file, it will run every method in that python file that starts with "test". You can be more specific on what to run by doing something like the following: (<i>Note that the syntax is different for pytest vs nosetests.</i>)
**Congratulations** on learning how to use **SeleniumBase**!
692
+
Congratulations on getting started with SeleniumBase!
688
693
689
694
<i>**Questions or Comments?**</i><br />
690
-
[](https://gitter.im/seleniumbase/SeleniumBase?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)<br>
695
+
[](https://gitter.im/seleniumbase/SeleniumBase?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)<br />
0 commit comments