Skip to content

Commit 4d3d43e

Browse files
authored
Merge pull request #798 from seleniumbase/add-sbase-mkpres-script
Add the "sbase mkpres" console script for making HTML presentations
2 parents 49695e9 + 8e6546c commit 4d3d43e

File tree

10 files changed

+401
-57
lines changed

10 files changed

+401
-57
lines changed

README.md

Lines changed: 53 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ pip install seleniumbase
112112
COMMANDS:
113113
install [DRIVER] [OPTIONS]
114114
mkdir [DIRECTORY]
115-
mkfile [FILE.py]
115+
mkfile [FILE.py] [OPTIONS]
116+
mkpres [FILE.py] [LANGUAGE OPTIONS]
116117
options (List common pytest options)
117118
print [FILE] [OPTIONS]
118119
translate [SB_FILE.py] [LANG] [ACTION]
@@ -152,53 +153,24 @@ sbase install chromedriver latest
152153
153154
(See [seleniumbase.io/seleniumbase/console_scripts/ReadMe/](https://seleniumbase.io/seleniumbase/console_scripts/ReadMe/) for more information on SeleniumBase console scripts.)
154155
155-
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Create and run tests:</h3>
156+
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Running tests:</h3>
156157
157-
🔵 ``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>
187159
188160
```bash
161+
cd examples/
189162
pytest test_demo_site.py
190163
```
191164
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``.)
194166
195167
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py"><img src="https://seleniumbase.io/cdn/gif/demo_page_1.gif" title="SeleniumBase Demo Page" /></a><br />
196168
197-
🔵 <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>
198170
199171
```bash
200-
cd examples/
201172
pytest my_first_test.py
173+
202174
pytest test_swag_labs.py
203175
```
204176
@@ -438,18 +410,56 @@ Here's the command-line option to add to tests: (See [examples/custom_settings.p
438410
Inside your tests, you can use ``self.data`` to access that.
439411
440412
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>
442414
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.
444416
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:
446418
447419
```bash
448420
sbase mkdir ui_tests
449-
cd ui_tests/
450-
pytest test_demo_site.py
451421
```
452422
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+
453463
--------
454464
455465
<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):
467477
self.assert_element("div#ARMY_OF_ROBOTS", timeout=1) # This should fail
468478
```
469479
470-
You can run it from the ``examples`` folder like this:
480+
You can run it from the ``examples/`` folder like this:
471481
472482
```bash
473483
pytest test_fail.py
@@ -589,7 +599,7 @@ pytest user_agent_test.py --agent="Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1
589599
590600
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Building Guided Tours for Websites:</h3>
591601
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.
593603
594604
595605
<a id="utilizing_advanced_features"></a>

examples/chart_maker/ReadMe.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<h3 align="left"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" width="360" /></h3>
1+
<h3 align="left"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" width="350" /></h3>
22

3-
<h3> 📊 ChartMaker 📈 </h3>
3+
<h2> 📊 ChartMaker 📈 </h2>
44

5-
SeleniumBase ChartMaker allows you to create HTML charts with Python. (Using HighCharts JS)
5+
<p>SeleniumBase ChartMaker lets you use Python to generate HTML charts from HighCharts JS.</p>
66

7-
<a href="https://seleniumbase.io/other/chart_presentation.html"><img width="500" src="https://seleniumbase.io/other/chart_presentation.gif" title="Screenshot"></a><br>
7+
<a href="https://seleniumbase.io/other/chart_presentation.html"><img width="480" src="https://seleniumbase.io/cdn/gif/chart_pres.gif" title="Chart Presentation"></a><br>
88

99
([Click to see a presentation with multiple charts](https://seleniumbase.io/other/chart_presentation.html))
1010

examples/presenter/ReadMe.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
<h1> 📰 Presenter 📑 </h1>
44

5-
<b>SeleniumBase Presenter allows you to create HTML presentations with Python.</b><br />
6-
(The "Reveal-JS" library is used for running the presentations.)
5+
<p>SeleniumBase Presenter lets you use Python to generate HTML presentations from Reveal JS.</p>
76

8-
**Here's a sample presentation:**
7+
<b>Here's a sample presentation:</b>
98

109
<a href="https://seleniumbase.io/other/presenter.html"><img width="500" src="https://seleniumbase.io/other/presenter.gif" title="Screenshot"></a><br>
1110

help_docs/chart_maker.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<h3 align="left"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" width="360" /></h3>
1+
<h3 align="left"><img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" alt="SeleniumBase" width="350" /></h3>
22

3-
<h3> 📊 ChartMaker 📈 </h3>
3+
<h2> 📊 ChartMaker 📈 </h2>
44

5-
SeleniumBase ChartMaker allows you to create HTML charts with Python. (Using HighCharts JS)
5+
<p>SeleniumBase ChartMaker lets you use Python to generate HTML charts from HighCharts JS.</p>
66

7-
<a href="https://seleniumbase.io/other/chart_presentation.html"><img width="500" src="https://seleniumbase.io/other/chart_presentation.gif" title="Screenshot"></a><br>
7+
<a href="https://seleniumbase.io/other/chart_presentation.html"><img width="480" src="https://seleniumbase.io/cdn/gif/chart_pres.gif" title="Chart Presentation"></a><br>
88

99
([Click to see a presentation with multiple charts](https://seleniumbase.io/other/chart_presentation.html))
1010

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ toml==0.10.2
7878
Pillow==6.2.2;python_version<"3.5"
7979
Pillow==7.2.0;python_version>="3.5" and python_version<"3.6"
8080
Pillow==8.1.0;python_version>="3.6"
81-
rich==9.9.0;python_version>="3.6" and python_version<"4.0"
81+
rich==9.10.0;python_version>="3.6" and python_version<"4.0"
8282
flake8==3.7.9;python_version<"3.5"
8383
flake8==3.8.4;python_version>="3.5"
8484
pyflakes==2.1.1;python_version<"3.5"

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "1.53.3"
2+
__version__ = "1.54.0"

seleniumbase/console_scripts/ReadMe.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,28 @@ methods, which are "open", "type", "click",
8181
basic boilerplate option, only the "open" method
8282
is included.
8383

84+
### mkpres
85+
86+
* Usage:
87+
``sbase mkpres [FILE.py] [LANGUAGE OPTIONS]``
88+
89+
* Example:
90+
``sbase mkpres new_presentation.py``
91+
92+
* Language Options:
93+
``--en`` / ``--English`` | ``--zh`` / ``--Chinese``
94+
``--nl`` / ``--Dutch`` | ``--fr`` / ``--French``
95+
``--it`` / ``--Italian`` | ``--ja`` / ``--Japanese``
96+
``--ko`` / ``--Korean`` | ``--pt`` / ``--Portuguese``
97+
``--ru`` / ``--Russian`` | ``--es`` / ``--Spanish``
98+
99+
* Output:
100+
Creates a new presentation with 3 example slides.
101+
If the file already exists, an error is raised.
102+
By default, the slides are written in English.
103+
Slides use "serif" theme & "fade" transition.
104+
This code can be used as a base boilerplate.
105+
84106
### options
85107

86108
* Usage:

seleniumbase/console_scripts/run.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
sbase install chromedriver
1010
sbase mkdir ui_tests
1111
sbase mkfile new_test.py
12+
sbase mkpres new_presentation.py
1213
sbase options
1314
sbase convert webdriver_unittest_file.py
1415
sbase print my_first_test.py -n
@@ -67,6 +68,7 @@ def show_basic_usage():
6768
sc += (" install [DRIVER] [OPTIONS]\n")
6869
sc += (" mkdir [DIRECTORY] [OPTIONS]\n")
6970
sc += (" mkfile [FILE.py] [OPTIONS]\n")
71+
sc += (" mkpres [FILE.py] [LANGUAGE OPTIONS]\n")
7072
sc += (" options (List common pytest options)\n")
7173
sc += (" print [FILE] [OPTIONS]\n")
7274
sc += (" translate [SB_FILE.py] [LANG] [ACTION]\n")
@@ -183,6 +185,33 @@ def show_mkfile_usage():
183185
print("")
184186

185187

188+
def show_mkpres_usage():
189+
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
190+
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
191+
cr = colorama.Style.RESET_ALL
192+
sc = (" " + c2 + "** " + c3 + "mkpres" + c2 + " **" + cr)
193+
print(sc)
194+
print("")
195+
print(" Usage:")
196+
print(" seleniumbase mkpres [FILE.py] [LANGUAGE OPTIONS]")
197+
print(" OR: sbase mkpres [FILE.py] [LANGUAGE OPTIONS]")
198+
print(" Example:")
199+
print(" sbase mkpres new_presentation.py")
200+
print(" Language Options:")
201+
print(" --en / --English | --zh / --Chinese")
202+
print(" --nl / --Dutch | --fr / --French")
203+
print(" --it / --Italian | --ja / --Japanese")
204+
print(" --ko / --Korean | --pt / --Portuguese")
205+
print(" --ru / --Russian | --es / --Spanish")
206+
print(" Output:")
207+
print(" Creates a new presentation with 3 example slides.")
208+
print(" If the file already exists, an error is raised.")
209+
print(" By default, the slides are written in English.")
210+
print(' Slides use "serif" theme & "fade" transition.')
211+
print(" This code can be used as a base boilerplate.")
212+
print("")
213+
214+
186215
def show_convert_usage():
187216
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
188217
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
@@ -540,6 +569,7 @@ def show_detailed_help():
540569
show_install_usage()
541570
show_mkdir_usage()
542571
show_mkfile_usage()
572+
show_mkpres_usage()
543573
show_convert_usage()
544574
show_print_usage()
545575
show_translate_usage()
@@ -591,6 +621,13 @@ def main():
591621
else:
592622
show_basic_usage()
593623
show_mkfile_usage()
624+
elif command == "mkpres":
625+
if len(command_args) >= 1:
626+
from seleniumbase.console_scripts import sb_mkpres
627+
sb_mkpres.main()
628+
else:
629+
show_basic_usage()
630+
show_mkpres_usage()
594631
elif command == "convert":
595632
if len(command_args) == 1:
596633
from seleniumbase.utilities.selenium_ide import convert_ide
@@ -718,6 +755,10 @@ def main():
718755
print("")
719756
show_mkfile_usage()
720757
return
758+
elif command_args[0] == "mkpres":
759+
print("")
760+
show_mkpres_usage()
761+
return
721762
elif command_args[0] == "convert":
722763
print("")
723764
show_convert_usage()

0 commit comments

Comments
 (0)