|
1 |
| -[<img src="https://cdn2.hubspot.net/hubfs/100006/images/fancy_logo_14.png" title="SeleniumBase" align="center" height="38">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)<br /> |
2 |
| - |
3 |
| -[<img src="https://img.shields.io/github/release/seleniumbase/SeleniumBase.svg?color=2277EE" alt="SeleniumBase" />](https://github.com/seleniumbase/SeleniumBase/releases) [<img src="https://img.shields.io/pypi/v/seleniumbase.svg?color=22AAEE" alt=" " />](https://pypi.python.org/pypi/seleniumbase) [<img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" alt=" " />](https://gitter.im/seleniumbase/SeleniumBase) [<img src="https://img.shields.io/travis/seleniumbase/SeleniumBase/master.svg" alt=" " />](https://travis-ci.org/seleniumbase/SeleniumBase) [<img src="https://github.com/seleniumbase/SeleniumBase/workflows/CI%20build/badge.svg">](https://github.com/seleniumbase/SeleniumBase/actions)<br /> |
4 |
| - |
5 |
| -A Python framework for Web UI testing and [site tours](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md) with [Selenium](https://selenium.dev/) and [pytest](https://docs.pytest.org/en/latest/index.html). |
| 1 | +<h2 align="center"><img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_i4.png" alt="SeleniumBase" height="46" /></h2> |
| 2 | + |
| 3 | +<h3 align="center"> Create automated tests for web and mobile. ✅</h3> |
| 4 | + |
| 5 | +<p align="center">SeleniumBase: A Python framework that uses <a href="https://docs.pytest.org/en/latest/index.html">pytest</a> and <a href="https://selenium.dev/">WebDriver</a> to make UI testing fast, easy, and reliable.</p> |
| 6 | + |
| 7 | +<p align="center"> |
| 8 | +<a href="https://github.com/seleniumbase/SeleniumBase/releases"> |
| 9 | +<img src="https://img.shields.io/github/release/seleniumbase/SeleniumBase.svg?color=2277EE" alt="Latest Release on GitHub" /></a> <a href="https://pypi.python.org/pypi/seleniumbase"> |
| 10 | +<img src="https://img.shields.io/pypi/v/seleniumbase.svg?color=22AAEE" alt="Latest Release on PyPI" /></a> <a href="https://travis-ci.org/seleniumbase/SeleniumBase"> |
| 11 | +<img src="https://img.shields.io/travis/seleniumbase/SeleniumBase/master.svg" alt="SeleniumBase on TravisCI" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/actions"> |
| 12 | +<img src="https://github.com/seleniumbase/SeleniumBase/workflows/CI%20build/badge.svg" alt="SeleniumBase GitHub Actions" /></a> <a href="https://gitter.im/seleniumbase/SeleniumBase"> |
| 13 | +<img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" alt="SeleniumBase" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/stargazers"> |
| 14 | +<img src="https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg?color=888CFA" alt="SeleniumBase" /></a> |
| 15 | +</p> |
| 16 | + |
| 17 | +<p align="center"> |
| 18 | +<a href="#python_installation">🚀 Get Started</a> | |
| 19 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/features_list.md">🦚 Features</a> | |
| 20 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md">🧙♂️ CMD Options</a> | |
| 21 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples">👩🏫 Examples</a> | |
| 22 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md">📊 Sample Reports</a> | |
| 23 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md">📖 API</a> | |
| 24 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/mobile_testing.md">📱 Mobile Testing</a> | |
| 25 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md">🚞 Site Tours</a> | |
| 26 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/visual_testing/ReadMe.md">👩🎨 Visual Testing</a> | |
| 27 | +<a href="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/translations">🌎 Translations</a> | |
| 28 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_ide/ReadMe.md">⏺️ Recorder</a> | |
| 29 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md">🌐 Grid-Use</a> | |
| 30 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/ReadMe.md">👩💻 MasterQA Tool</a> | |
| 31 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/github/workflows/ReadMe.md">🛩️ GitHub CI</a> | |
| 32 | +<a href="https://gitter.im/seleniumbase/SeleniumBase">👋 Chat</a> | |
| 33 | +<a href="https://github.com/seleniumbase/SeleniumBase/releases">🗺️ Releases</a> |
| 34 | +</p> |
| 35 | + |
| 36 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_swag_labs.py"><img src="https://cdn2.hubspot.net/hubfs/100006/images/swag_mobile.gif" /></a><br /> |
| 37 | + |
| 38 | +(<i>Above: [test_swag_labs.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_swag_labs.py) from [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) running in Mobile Mode.</i>)<br /> |
| 39 | +```bash |
| 40 | +pytest test_swag_labs.py --mobile |
| 41 | +``` |
| 42 | +------ |
| 43 | +<div>SeleniumBase's command-line options allow you to run the same test using different browsers and environments.</div> |
6 | 44 |
|
7 |
| -<img src="https://cdn2.hubspot.net/hubfs/100006/images/swag_labs_gif.gif" title="SeleniumBase"><br /> |
8 |
| -(<i>Above: [test_swag_labs.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_swag_labs.py) from [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) running in Demo Mode.</i>)<br /> |
| 45 | +(<i>Below: [test_swag_labs.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_swag_labs.py) from [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) running in Demo Mode.</i>) |
9 | 46 | ```bash
|
10 | 47 | pytest test_swag_labs.py --demo
|
11 | 48 | ```
|
| 49 | +<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_swag_labs.py"><img src="https://cdn2.hubspot.net/hubfs/100006/images/swag_labs_gif.gif" /></a><br /> |
12 | 50 |
|
13 |
| -## <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Features: |
14 |
| -* Simplifies the process of creating of web & mobile tests. |
15 |
| -* Includes [command-line options](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md) for making [reports](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md), etc. |
16 |
| -* Uses reliable, smart-waiting code to prevent flakiness. |
17 |
| -* Multiplies the abilities of [pytest](https://pytest.org) and enhances [Selenium](https://www.seleniumhq.org/). |
18 |
| -* Includes tools for [assisted-QA](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/ReadMe.md), [visual testing](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/visual_testing/ReadMe.md), & [web tours](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md). |
19 |
| -* Integrates with [Selenium Grid](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md), [Katalon Recorder](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_ide/ReadMe.md), & [MySQL](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/core/testcase_manager.py). |
20 |
| -* To see all features [click here](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/features_list.md). To see all methods, [click here](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md). |
21 |
| -* To see examples [click here](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/ReadMe.md). To see all help docs, [click here](https://github.com/seleniumbase/SeleniumBase/tree/master/help_docs). |
22 | 51 |
|
23 | 52 | <a id="python_installation"></a>
|
24 | 53 | ## <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Quick Start
|
@@ -69,7 +98,29 @@ pytest my_first_test.py
|
69 | 98 | * On Linux ``--headless`` is the default behavior (running with no GUI). You can also run in headless mode on any OS. If your Linux machine has a GUI and you want to see the web browser as tests run, add ``--headed`` or ``--gui``.
|
70 | 99 |
|
71 | 100 | **Here's an example test, [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py):**<br />
|
72 |
| -<img src="https://cdn2.hubspot.net/hubfs/100006/my_first_test_py_4.png" title="My First SeleniumBase Test"><br /> |
| 101 | +```python |
| 102 | +from seleniumbase import BaseCase |
| 103 | + |
| 104 | +class MyTestClass(BaseCase): |
| 105 | + |
| 106 | + def test_basic(self): |
| 107 | + self.open("https://xkcd.com/353/") |
| 108 | + self.assert_title("xkcd: Python") |
| 109 | + self.assert_element('img[alt="Python"]') |
| 110 | + self.click('a[rel="license"]') |
| 111 | + self.assert_text("free to copy and reuse") |
| 112 | + self.go_back() |
| 113 | + self.click_link_text("About") |
| 114 | + self.assert_text("xkcd.com", "h2") |
| 115 | + self.open("://store.xkcd.com/collections/everything") |
| 116 | + self.update_text("input.search-input", "xkcd book\n") |
| 117 | + self.assert_exact_text("xkcd: volume 0", "h3") |
| 118 | +``` |
| 119 | +<img src="https://cdn2.hubspot.net/hubfs/100006/images/my_first_test_gif.gif" title="SeleniumBase"><br /> |
| 120 | +```bash |
| 121 | +pytest my_first_test.py --demo |
| 122 | +``` |
| 123 | + |
73 | 124 | * By default, **[CSS Selectors](https://www.w3schools.com/cssref/css_selectors.asp)** are used for finding page elements.
|
74 | 125 | * If you're new to CSS Selectors, games like [Flukeout](http://flukeout.github.io/) can help you learn.
|
75 | 126 | * Here are some common ``SeleniumBase`` methods you might find in tests:
|
@@ -110,10 +161,14 @@ self.update_text("input", "dogs\n")
|
110 | 161 | The same command with regular WebDriver is very messy:
|
111 | 162 | (<i>And it doesn't include SeleniumBase smart-waiting.</i>)
|
112 | 163 | ```python
|
113 |
| -self.driver.find_element_by_css_selector("input").clear() # Not always needed |
114 |
| -self.driver.find_element_by_css_selector("input").send_keys("dogs") |
115 |
| -self.driver.find_element_by_css_selector("input").submit() |
116 |
| -``` |
| 164 | +from selenium.webdriver.common.by import By |
| 165 | +element = self.driver.find_element(by=By.CSS_SELECTOR, value="input") |
| 166 | +element.clear() # Not always needed |
| 167 | +element.send_keys("dogs") |
| 168 | +element.submit() |
| 169 | +``` |
| 170 | +As you can see, the old WebDriver way is very bad! |
| 171 | +Use SeleniumBase to make testing much easier! |
117 | 172 | (<i>You can still use ``self.driver`` in your code.</i>)
|
118 | 173 |
|
119 | 174 | #### **Run tests with ``pytest`` or ``nosetests`` in any browser:**<br />
|
|
0 commit comments