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
(See [seleniumbase.io/seleniumbase/console_scripts/ReadMe/](https://seleniumbase.io/seleniumbase/console_scripts/ReadMe/) for more information on SeleniumBase console scripts.)
154
155
155
-
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" />Create and run tests:</h3>
🔵 ``sbase mkdir DIR`` creates a folder with sample tests:
158
-
159
-
```bash
160
-
sbase mkdir ui_tests
161
-
cd ui_tests/
162
-
```
163
-
164
-
> That folder will have the following files:
165
-
166
-
```
167
-
ui_tests/
168
-
├── __init__.py
169
-
├── boilerplates/
170
-
│ ├── __init__.py
171
-
│ ├── base_test_case.py
172
-
│ ├── boilerplate_test.py
173
-
│ ├── page_objects.py
174
-
│ └── samples/
175
-
│ ├── __init__.py
176
-
│ ├── google_objects.py
177
-
│ └── google_test.py
178
-
├── my_first_test.py
179
-
├── parameterized_test.py
180
-
├── pytest.ini
181
-
├── requirements.txt
182
-
├── setup.cfg
183
-
└── test_demo_site.py
184
-
```
185
-
186
-
🔵 <b>Run a sample test with ``pytest``:</b>
158
+
🔵 <b>If you've cloned SeleniumBase from GitHub, you can run sample tests from the [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder:</b>
187
159
188
160
```bash
161
+
cd examples/
189
162
pytest test_demo_site.py
190
163
```
191
164
192
-
> (Chrome is the default browser if not specified with ``--browser=BROWSER``.)
193
-
> (On Linux, ``--headless`` is the default behavior. 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``.)
165
+
> (Chrome is the default browser if not specified with ``--browser=BROWSER``. On Linux, ``--headless`` is the default behavior. 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``.)
🔵 <b>If you've cloned SeleniumBase from GitHub, you can run sample tests from the [SeleniumBase/examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder:</b>
169
+
🔵 <b>Here are more examples that you can run:</b>
198
170
199
171
```bash
200
-
cd examples/
201
172
pytest my_first_test.py
173
+
202
174
pytest test_swag_labs.py
203
175
```
204
176
@@ -438,18 +410,56 @@ Here's the command-line option to add to tests: (See [examples/custom_settings.p
438
410
Inside your tests, you can use ``self.data`` to access that.
439
411
440
412
441
-
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Test Directory Customization:</h3>
413
+
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Test Directory Configuration:</h3>
442
414
443
-
🔵 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.) These files specify default configuration details for tests. (For nosetest runs, you can also specify a .cfg file by using ``--config``. Example ``nosetests [MY_TEST.py] --config=[MY_CONFIG.cfg]``)
415
+
🔵 When running tests with **pytest**, you'll want a copy of **[pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini)**in your root folders. When running tests with **nosetests**, you'll want a copy of **[setup.cfg](https://github.com/seleniumbase/SeleniumBase/blob/master/setup.cfg)** in your root folders. These files specify default configuration details for tests. Folders should also include a blank ``__init__.py`` file, which allows your tests to import files from that folder.
444
416
445
-
🔵 As a shortcut, you'll be able to run ``sbase mkdir [DIRECTORY]``to create a new folder that already contains necessary files and some example tests that you can run.
417
+
🔵 ``sbase mkdir DIR`` creates a folder with config files and sample tests:
446
418
447
419
```bash
448
420
sbase mkdir ui_tests
449
-
cd ui_tests/
450
-
pytest test_demo_site.py
451
421
```
452
422
423
+
> That new folder will have these files:
424
+
425
+
```bash
426
+
ui_tests/
427
+
├── __init__.py
428
+
├── boilerplates/
429
+
│ ├── __init__.py
430
+
│ ├── base_test_case.py
431
+
│ ├── boilerplate_test.py
432
+
│ ├── page_objects.py
433
+
│ └── samples/
434
+
│ ├── __init__.py
435
+
│ ├── google_objects.py
436
+
│ └── google_test.py
437
+
├── my_first_test.py
438
+
├── parameterized_test.py
439
+
├── pytest.ini
440
+
├── requirements.txt
441
+
├── setup.cfg
442
+
└── test_demo_site.py
443
+
```
444
+
445
+
<b>ProTip™:</b> You can also create a boilerplate folder without any sample tests in it by adding ``-b`` or ``--basic`` to the ``sbase mkdir`` command:
446
+
447
+
```bash
448
+
sbase mkdir ui_tests --basic
449
+
```
450
+
451
+
> That new folder will have these files:
452
+
453
+
```bash
454
+
ui_tests/
455
+
├── __init__.py
456
+
├── pytest.ini
457
+
├── requirements.txt
458
+
└── setup.cfg
459
+
```
460
+
461
+
Of those files, the ``pytest.ini`` config file is the most important, followed by a blank ``__init__.py`` file. There's also a ``setup.cfg`` file (only needed for nosetests). Finally, the ``requirements.txt`` file can be used to help you install seleniumbase into your environments (if it's not already installed).
462
+
453
463
--------
454
464
455
465
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Log files from failed tests:</h3>
@@ -467,7 +477,7 @@ class MyTestClass(BaseCase):
467
477
self.assert_element("div#ARMY_OF_ROBOTS", timeout=1) # This should fail
468
478
```
469
479
470
-
You can run it from the ``examples`` folder like this:
480
+
You can run it from the ``examples/`` folder like this:
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Building Guided Tours for Websites:</h3>
591
601
592
-
🔵 Learn about <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md">SeleniumBase Interactive Walkthroughs</a> (in the ``examples/tour_examples`` folder). It's great for prototyping a website onboarding experience.
602
+
🔵 Learn about <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md">SeleniumBase Interactive Walkthroughs</a> (in the ``examples/tour_examples/`` folder). It's great for prototyping a website onboarding experience.
0 commit comments