|
1 |
| -<img src="https://cdn2.hubspot.net/hubfs/100006/images/expanded_icons_2.png" title="SeleniumBase" height="145"> |
| 1 | +<img src="https://cdn2.hubspot.net/hubfs/100006/images/SB_Logo3d.png" title="SeleniumBase" height="48"> |
2 | 2 |
|
3 |
| -## SeleniumBase · [](https://pypi.python.org/pypi/seleniumbase) [](https://travis-ci.org/seleniumbase/SeleniumBase)<br /> |
| 3 | +[](https://pypi.python.org/pypi/seleniumbase) [](https://travis-ci.org/seleniumbase/SeleniumBase) [](https://github.com/seleniumbase/SeleniumBase/stargazers)<br /> |
4 | 4 |
|
5 |
| -SeleniumBase simplifies browser-based test automation with [WebDriver](https://docs.microsoft.com/en-us/microsoft-edge/webdriver) & [Pytest](https://github.com/pytest-dev/pytest). |
| 5 | +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/)) |
| 7 | +#### Quick start in a few steps: (Requires [Python](https://www.python.org/downloads/) and [Git](https://git-scm.com/)) |
8 | 8 |
|
9 | 9 | ```bash
|
10 |
| -python -m pip install -U pip |
11 |
| -pip install -U seleniumbase --no-cache-dir |
| 10 | +git clone https://github.com/seleniumbase/SeleniumBase.git |
| 11 | +cd SeleniumBase |
| 12 | +python -m pip install pip --upgrade |
| 13 | +pip install -r requirements.txt --upgrade |
| 14 | +python setup.py develop |
| 15 | + |
12 | 16 | seleniumbase install chromedriver
|
13 |
| -seleniumbase mkdir browser_tests |
14 |
| -cd browser_tests |
| 17 | + |
| 18 | +cd examples |
15 | 19 | pytest my_first_test.py --browser=chrome
|
16 | 20 | ```
|
17 | 21 |
|
18 |
| -The ``seleniumbase mkdir [NAME]`` command creates a new folder with sample tests. To use a different browser other than Chrome, use ``seleniumbase install [DRIVER]`` with ``edgedriver`` (Microsoft Edge) or ``geckodriver`` (Firefox). Then you can use ``--browser=edge`` or ``--browser=firefox`` to run tests on those browsers. ``--browser=chrome`` is the default option. |
| 22 | +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): |
| 23 | + |
| 24 | +```bash |
| 25 | +seleniumbase install geckodriver |
| 26 | +nosetests my_first_test.py --browser=firefox |
| 27 | +``` |
| 28 | + |
| 29 | +Try out Demo Mode to see what what's being tested in real time! (Chrome is the default browser if not specified.) |
19 | 30 |
|
20 |
| -**Slow-motion demo of [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) running:**<br> |
21 |
| -<br> |
| 31 | +```bash |
| 32 | +pytest my_first_test.py --demo_mode |
| 33 | +``` |
| 34 | + |
| 35 | +<br /> |
| 36 | +(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/)) |
22 | 37 |
|
23 | 38 | 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.
|
24 | 39 |
|
| 40 | +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). |
| 41 | + |
| 42 | +```bash |
| 43 | +cd tour_examples |
| 44 | +pytest google_tour.py |
| 45 | +``` |
| 46 | + |
| 47 | +<br /> |
| 48 | +(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)) |
| 49 | + |
25 | 50 | For more detailed steps on getting started, see the [**Detailed Instructions**](#seleniumbase_installation) section.
|
26 | 51 |
|
27 | 52 | ### Learn More:
|
@@ -205,13 +230,45 @@ pytest my_test_suite.py --browser=firefox
|
205 | 230 |
|
206 | 231 | If you want to run tests headlessly, use ``--headless``, which you'll need to do if your system lacks a GUI interface. Even if your system does have a GUI interface, it may still support headless browser automation.
|
207 | 232 |
|
| 233 | +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. |
| 234 | + |
| 235 | +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. |
| 236 | + |
| 237 | +<img src="https://cdn2.hubspot.net/hubfs/100006/images/logo_base_4b.png" title="SeleniumBase" height="120"> |
| 238 | + |
| 239 | +###  **Using SeleniumBase as your personal framework:** |
| 240 | + |
| 241 | +You can install SeleniumBase without cloning the repo by doing this: |
| 242 | + |
| 243 | +```bash |
| 244 | +python -m pip install -U pip |
| 245 | +pip install -U seleniumbase --no-cache-dir |
| 246 | +``` |
| 247 | + |
| 248 | +Now you can install webdrivers by doing this: |
| 249 | + |
| 250 | +```bash |
| 251 | +seleniumbase install chromedriver |
| 252 | +seleniumbase install geckodriver |
| 253 | +``` |
| 254 | + |
| 255 | +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. |
| 256 | + |
| 257 | +When creating your own test directories, keep these two things in mind: |
| 258 | + |
208 | 259 | 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. (Subfolders should include a blank ``__init__.py`` file.)
|
209 | 260 |
|
210 | 261 | 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.)
|
211 | 262 |
|
212 |
| -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. |
| 263 | +(You'll be able to customize those files as needed.) |
213 | 264 |
|
214 |
| -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. |
| 265 | +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: |
| 266 | + |
| 267 | +```bash |
| 268 | +seleniumbase mkdir browser_tests |
| 269 | +cd browser_tests |
| 270 | +pytest my_first_test.py --browser=chrome |
| 271 | +``` |
215 | 272 |
|
216 | 273 | <img src="https://cdn2.hubspot.net/hubfs/100006/images/logo_base_4b.png" title="SeleniumBase" height="120">
|
217 | 274 |
|
|
0 commit comments