Skip to content

Commit a4455f4

Browse files
authored
Merge pull request #603 from seleniumbase/update-presenter
SeleniumBase Presenter is out of beta!
2 parents b56e01b + e72522c commit a4455f4

File tree

16 files changed

+442
-130
lines changed

16 files changed

+442
-130
lines changed

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ lib64
1919
__pycache__
2020

2121
# Python3 pyvenv
22+
env
2223
venv
2324
sbase
2425
sbase*
@@ -74,9 +75,6 @@ archived_logs
7475
geckodriver.log
7576
pytestdebug.log
7677

77-
# Presentations
78-
presentations_saved
79-
8078
# Reports
8179
latest_report
8280
report_archives
@@ -85,6 +83,10 @@ html_report.html
8583
report.html
8684
report.xml
8785

86+
# Presentations
87+
presentations_saved
88+
saved_presentations
89+
8890
# Tours
8991
tours_exported
9092

examples/presenter/ReadMe.md

Lines changed: 101 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
# 📰 Presenter 📰
44

5-
SeleniumBase Presenter allows you to create an HTML presentation with only a few lines of Python.
5+
SeleniumBase Presenter allows you to create HTML presentations with Python.
66
The Reveal-JS library is used for running the presentations.
77

8-
**Here's a sample slide:**
8+
**Here's a sample presentation:**
99

10-
<img width="90%" src="https://seleniumbase.io/other/presenter_screen.png" title="Screenshot"><br>
10+
<a href="https://seleniumbase.io/other/presenter.html"><img width="500" src="https://seleniumbase.io/other/presenter.gif" title="Screenshot"></a><br>
1111

1212
Slides can include HTML, code, images, and iframes.
1313

@@ -21,11 +21,15 @@ pytest my_presentation.py
2121
### Creating a new presentation:
2222

2323
```python
24-
self.create_presentation(name=None, show_notes=True)
24+
self.create_presentation(name=None, theme="serif", show_notes=True)
2525
""" Creates a Reveal-JS presentation that you can add slides to.
2626
@Params
2727
name - If creating multiple presentations at the same time,
2828
use this to specify the name of the current presentation.
29+
theme - Set a theme with a unique style for the presentation.
30+
Valid themes: "serif" (default), "sky", "white", "black",
31+
"simple", "league", "moon", "night",
32+
"beige", "blood", and "solarized".
2933
show_notes - When set to True, the Notes feature becomes enabled,
3034
which allows presenters to see notes next to slides.
3135
"""
@@ -40,14 +44,15 @@ Notes are enabled by default unless you specify:
4044

4145
```python
4246
self.add_slide(content=None, image=None, code=None, iframe=None,
43-
notes=None, name=None)
47+
content2=None, notes=None, name=None)
4448
""" Allows the user to add slides to a presentation.
4549
@Params
4650
content - The HTML content to display on the presentation slide.
4751
image - Attach an image (from a URL link) to the slide.
4852
code - Attach code of any programming language to the slide.
4953
Language-detection will be used to add syntax formatting.
5054
iframe - Attach an iFrame (from a URL link) to the slide.
55+
content2 - HTML content to display after adding an image or code.
5156
notes - Additional notes to include with the slide.
5257
ONLY SEEN if show_notes is set for the presentation.
5358
name - If creating multiple presentations at the same time,
@@ -59,11 +64,19 @@ self.add_slide(content=None, image=None, code=None, iframe=None,
5964
### Running a presentation:
6065

6166
```python
62-
self.begin_presentation(filename="my_presentation.html", name=None)
63-
""" Begin a Reveal-JS Presentation in the web browser. """
67+
self.begin_presentation(filename="my_presentation.html", interval=0)
68+
""" Begin a Reveal-JS Presentation in the web browser.
69+
@Params
70+
name - If creating multiple presentations at the same time,
71+
use this to select the one you wish to add slides to.
72+
filename - The name of the HTML file that you wish to
73+
save the presentation to. (filename must end in ".html")
74+
interval - The delay time between autoplaying slides. (in seconds)
75+
If set to 0 (default), autoplay is disabled.
76+
"""
6477
```
6578

66-
Before the presentation is run, the full HTML is saved to the ``presentations_saved/`` folder.
79+
Before the presentation is run, the full HTML is saved to the ``saved_presentations/`` folder.
6780

6881

6982
All methods have the optional ``name`` argument, which is only needed if you're creating multiple presentations at once.
@@ -77,22 +90,44 @@ from seleniumbase import BaseCase
7790
class MyPresenterClass(BaseCase):
7891

7992
def test_presenter(self):
80-
self.create_presentation()
93+
self.create_presentation(theme="serif")
94+
self.add_slide(
95+
'<h1>Welcome</h1><br />\n'
96+
'<h3>Press the <b>Right Arrow</b></h3>')
8197
self.add_slide(
82-
"<h2>Welcome!</h2>"
83-
"<h4>Enjoy the Presentation!</h4>")
98+
'<h3>SeleniumBase Presenter</h3><br />\n'
99+
'<img width="240" src="https://seleniumbase.io/img/logo3a.png" />'
100+
'<span style="margin:144px;" />'
101+
'<img src="https://seleniumbase.io/other/python_3d_logo.png" />'
102+
'<br /><br />\n<h4>Create presentations with <b>Python</b></h4>')
84103
self.add_slide(
85-
'<h3>SeleniumBase "Presenter"</h3>'
86-
'<img src="https://seleniumbase.io/img/logo3a.png"></img>'
87-
'<h4>A tool for creating presentations</h4>')
104+
'<h3>Make slides using <b>HTML</b>:</h3><br />\n'
105+
'<table style="padding:10px;border:4px solid black;font-size:50;">'
106+
'\n<tr style="background-color:CDFFFF;">\n'
107+
'<th>Row ABC</th><th>Row XYZ</th></tr>\n'
108+
'<tr style="background-color:DCFDDC;">'
109+
'<td>Value ONE</td><td>Value TWO</td></tr>\n'
110+
'<tr style="background-color:DFDFFB;">\n'
111+
'<td>Value THREE</td><td>Value FOUR</td></tr>\n'
112+
'</table><br />\n<h4>(HTML <b>table</b> example)</h4>')
88113
self.add_slide(
89-
'<h3>You can add HTML to any slide:</h3><br />'
90-
'<table style="padding:10px;border:4px solid black;font-size:60;">'
91-
'<tr><th>Row 1</th><th>Row 2</th></tr>'
92-
'<tr><td>Value 1</td><td>Value 2</td></tr></table><br />'
93-
'<h4>(HTML table example)</h4>')
114+
'<h3>Keyboard Shortcuts:</h3>\n'
115+
'<table style="padding:10px;border:4px solid black;font-size:30;'
116+
'background-color:FFFFDD;">\n'
117+
'<tr><th>Key</th><th>Action</th></tr>\n'
118+
'<tr><td><b>=></b></td><td>Next Slide (N also works)</td></tr>\n'
119+
'<tr><td><b><=</b></td><td>Previous Slide (P also works)</td></tr>'
120+
'\n<tr><td>F</td><td>Full Screen Mode</td></tr>\n'
121+
'<tr><td>O</td><td>Overview Mode Toggle</td></tr>\n'
122+
'<tr><td>esc</td><td>Exit Full Screen / Overview Mode</td></tr>\n'
123+
'<tr><td><b>.</b></td><td>Pause/Resume Toggle</td></tr>\n'
124+
'<tr><td>space</td><td>Next Slide (alternative)</td></tr></table>'
125+
)
94126
self.add_slide(
95-
"<h3>You can display code:</h3>",
127+
'<h3>Add <b>images</b> to slides:</h3>',
128+
image="https://seleniumbase.io/other/seagulls.jpg")
129+
self.add_slide(
130+
'<h3>Add <b>code</b> to slides:</h3>',
96131
code=(
97132
'from seleniumbase import BaseCase\n\n'
98133
'class MyTestClass(BaseCase):\n\n'
@@ -107,26 +142,60 @@ class MyPresenterClass(BaseCase):
107142
' self.assert_text("free to copy and reuse")\n'
108143
' self.go_back()\n'
109144
' self.click_link_text("About")\n'
110-
' self.assert_exact_text("xkcd.com", "h2")\n'))
145+
' self.assert_exact_text("xkcd.com", "h2")'))
111146
self.add_slide(
112-
"<h3>You can highlight code:</h3>",
147+
"<h3>Highlight <b>code</b> in slides:</h3>",
113148
code=(
114149
'from seleniumbase import BaseCase\n\n'
115150
'<mark>class MyTestClass(BaseCase):</mark>\n\n'
116151
' def test_basic(self):\n'
117152
' self.open("https://store.xkcd.com/search")\n'
118-
' self.type(\'input[name="q"]\', "xkcd book\\n")\n'))
153+
' self.type(\'input[name="q"]\', "xkcd book\\n")\n'
154+
' self.assert_text("xkcd: volume 0", "h3")'))
119155
self.add_slide(
120-
"<h3>You can add notes to slides:</h3>",
121-
notes="<h2><ul><li>Note A!<li>Note B!<li>Note C!<li>Note D!</h2>")
156+
'<h3>Add <b>iFrames</b> to slides:</h3>',
157+
iframe="https://seleniumbase.io/demo_page")
122158
self.add_slide(
123-
"<h3>You can add images to slides:</h3>",
124-
image="https://seleniumbase.io/img/sb_logo_10.png")
159+
'<h3>Getting started is <b>easy</b>:</h3>',
160+
code=(
161+
'from seleniumbase import BaseCase\n\n'
162+
'class MyPresenterClass(BaseCase):\n\n'
163+
' def test_presenter(self):\n'
164+
' self.create_presentation()\n'
165+
' self.add_slide("Welcome to Presenter!")\n'
166+
' self.add_slide(\n'
167+
' "Add code to slides:",\n'
168+
' code=(\n'
169+
' "from seleniumbase import BaseCase\\n\\n"\n'
170+
' "class MyPresenterClass(BaseCase):\\n\\n"\n'
171+
' " def test_presenter(self):\\n"\n'
172+
' " self.create_presentation()\\n"))\n'
173+
' self.begin_presentation(filename="demo.html")'))
125174
self.add_slide(
126-
"<h3>You can add iframes to slides:</h3>",
127-
iframe="https://seleniumbase.io/demo_page")
128-
self.add_slide("<h1>The End</h1>")
129-
self.begin_presentation()
175+
'<h3>Include <b>notes</b> with slides:</h3><br />',
176+
code=('self.add_slide("[Your HTML goes here]",\n'
177+
' code="[Your software code goes here]",\n'
178+
' content2="[Additional HTML goes here]",\n'
179+
' notes="[Attached speaker notes go here]"\n'
180+
' "[Note A! -- Note B! -- Note C! ]")'),
181+
notes='<h2><ul><li>Note A!<li>Note B!<li>Note C!<li>Note D!</h2>',
182+
content2="<h4>(Notes can include HTML tags)</h4>")
183+
self.add_slide(
184+
'<h3>Multiple <b>themes</b> available:</h3>',
185+
code=(
186+
'self.create_presentation(theme="serif")\n\n'
187+
'self.create_presentation(theme="sky")\n\n'
188+
'self.create_presentation(theme="simple")\n\n'
189+
'self.create_presentation(theme="white")\n\n'
190+
'self.create_presentation(theme="moon")\n\n'
191+
'self.create_presentation(theme="black")\n\n'
192+
'self.create_presentation(theme="night")\n\n'
193+
'self.create_presentation(theme="beige")\n\n'
194+
'self.create_presentation(theme="league")'))
195+
self.add_slide(
196+
'<h2><b>The End</b></h2>',
197+
image="https://seleniumbase.io/img/sb_logo_10.png")
198+
self.begin_presentation(filename="presenter.html", interval=0)
130199
```
131200

132201
#### This example is from [my_presentation.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/presenter/my_presentation.py), which you can run from the ``examples/presenter`` folder with the following command:
@@ -140,7 +209,7 @@ pytest my_presentation.py
140209
If you want to save the presentation you created as an HTML file, use:
141210

142211
```python
143-
self.save_presentation(filename="my_presentation.html", name=None)
212+
self.save_presentation(filename="my_presentation.html")
144213
```
145214

146215
Presentations automatically get saved when calling:

examples/presenter/my_presentation.py

Lines changed: 79 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,44 @@
44
class MyPresenterClass(BaseCase):
55

66
def test_presenter(self):
7-
self.create_presentation()
7+
self.create_presentation(theme="serif")
88
self.add_slide(
9-
"<h2>Welcome!</h2>"
10-
"<h4>Enjoy the Presentation!</h4>")
9+
'<h1>Welcome</h1><br />\n'
10+
'<h3>Press the <b>Right Arrow</b></h3>')
1111
self.add_slide(
12-
'<h3>SeleniumBase "Presenter"</h3>'
13-
'<img src="https://seleniumbase.io/img/logo3a.png"></img>'
14-
'<h4>A tool for creating presentations</h4>')
12+
'<h3>SeleniumBase Presenter</h3><br />\n'
13+
'<img width="240" src="https://seleniumbase.io/img/logo3a.png" />'
14+
'<span style="margin:144px;" />'
15+
'<img src="https://seleniumbase.io/other/python_3d_logo.png" />'
16+
'<br /><br />\n<h4>Create presentations with <b>Python</b></h4>')
1517
self.add_slide(
16-
'<h3>You can add HTML to any slide:</h3><br />'
17-
'<table style="padding:10px;border:4px solid black;font-size:60;">'
18-
'<tr><th>Row 1</th><th>Row 2</th></tr>'
19-
'<tr><td>Value 1</td><td>Value 2</td></tr></table><br />'
20-
'<h4>(HTML table example)</h4>')
18+
'<h3>Make slides using <b>HTML</b>:</h3><br />\n'
19+
'<table style="padding:10px;border:4px solid black;font-size:50;">'
20+
'\n<tr style="background-color:CDFFFF;">\n'
21+
'<th>Row ABC</th><th>Row XYZ</th></tr>\n'
22+
'<tr style="background-color:DCFDDC;">'
23+
'<td>Value ONE</td><td>Value TWO</td></tr>\n'
24+
'<tr style="background-color:DFDFFB;">\n'
25+
'<td>Value THREE</td><td>Value FOUR</td></tr>\n'
26+
'</table><br />\n<h4>(HTML <b>table</b> example)</h4>')
2127
self.add_slide(
22-
"<h3>You can display code:</h3>",
28+
'<h3>Keyboard Shortcuts:</h3>\n'
29+
'<table style="padding:10px;border:4px solid black;font-size:30;'
30+
'background-color:FFFFDD;">\n'
31+
'<tr><th>Key</th><th>Action</th></tr>\n'
32+
'<tr><td><b>=></b></td><td>Next Slide (N also works)</td></tr>\n'
33+
'<tr><td><b><=</b></td><td>Previous Slide (P also works)</td></tr>'
34+
'\n<tr><td>F</td><td>Full Screen Mode</td></tr>\n'
35+
'<tr><td>O</td><td>Overview Mode Toggle</td></tr>\n'
36+
'<tr><td>esc</td><td>Exit Full Screen / Overview Mode</td></tr>\n'
37+
'<tr><td><b>.</b></td><td>Pause/Resume Toggle</td></tr>\n'
38+
'<tr><td>space</td><td>Next Slide (alternative)</td></tr></table>'
39+
)
40+
self.add_slide(
41+
'<h3>Add <b>images</b> to slides:</h3>',
42+
image="https://seleniumbase.io/other/seagulls.jpg")
43+
self.add_slide(
44+
'<h3>Add <b>code</b> to slides:</h3>',
2345
code=(
2446
'from seleniumbase import BaseCase\n\n'
2547
'class MyTestClass(BaseCase):\n\n'
@@ -34,23 +56,57 @@ def test_presenter(self):
3456
' self.assert_text("free to copy and reuse")\n'
3557
' self.go_back()\n'
3658
' self.click_link_text("About")\n'
37-
' self.assert_exact_text("xkcd.com", "h2")\n'))
59+
' self.assert_exact_text("xkcd.com", "h2")'))
3860
self.add_slide(
39-
"<h3>You can highlight code:</h3>",
61+
"<h3>Highlight <b>code</b> in slides:</h3>",
4062
code=(
4163
'from seleniumbase import BaseCase\n\n'
4264
'<mark>class MyTestClass(BaseCase):</mark>\n\n'
4365
' def test_basic(self):\n'
4466
' self.open("https://store.xkcd.com/search")\n'
45-
' self.type(\'input[name="q"]\', "xkcd book\\n")\n'))
67+
' self.type(\'input[name="q"]\', "xkcd book\\n")\n'
68+
' self.assert_text("xkcd: volume 0", "h3")'))
4669
self.add_slide(
47-
"<h3>You can add notes to slides:</h3>",
48-
notes="<h2><ul><li>Note A!<li>Note B!<li>Note C!<li>Note D!</h2>")
70+
'<h3>Add <b>iFrames</b> to slides:</h3>',
71+
iframe="https://seleniumbase.io/demo_page")
4972
self.add_slide(
50-
"<h3>You can add images to slides:</h3>",
51-
image="https://seleniumbase.io/img/sb_logo_10.png")
73+
'<h3>Getting started is <b>easy</b>:</h3>',
74+
code=(
75+
'from seleniumbase import BaseCase\n\n'
76+
'class MyPresenterClass(BaseCase):\n\n'
77+
' def test_presenter(self):\n'
78+
' self.create_presentation()\n'
79+
' self.add_slide("Welcome to Presenter!")\n'
80+
' self.add_slide(\n'
81+
' "Add code to slides:",\n'
82+
' code=(\n'
83+
' "from seleniumbase import BaseCase\\n\\n"\n'
84+
' "class MyPresenterClass(BaseCase):\\n\\n"\n'
85+
' " def test_presenter(self):\\n"\n'
86+
' " self.create_presentation()\\n"))\n'
87+
' self.begin_presentation(filename="demo.html")'))
5288
self.add_slide(
53-
"<h3>You can add iframes to slides:</h3>",
54-
iframe="https://seleniumbase.io/demo_page")
55-
self.add_slide("<h1>The End</h1>")
56-
self.begin_presentation()
89+
'<h3>Include <b>notes</b> with slides:</h3><br />',
90+
code=('self.add_slide("[Your HTML goes here]",\n'
91+
' code="[Your software code goes here]",\n'
92+
' content2="[Additional HTML goes here]",\n'
93+
' notes="[Attached speaker notes go here]"\n'
94+
' "[Note A! -- Note B! -- Note C! ]")'),
95+
notes='<h2><ul><li>Note A!<li>Note B!<li>Note C!<li>Note D!</h2>',
96+
content2="<h4>(Notes can include HTML tags)</h4>")
97+
self.add_slide(
98+
'<h3>Multiple <b>themes</b> available:</h3>',
99+
code=(
100+
'self.create_presentation(theme="serif")\n\n'
101+
'self.create_presentation(theme="sky")\n\n'
102+
'self.create_presentation(theme="simple")\n\n'
103+
'self.create_presentation(theme="white")\n\n'
104+
'self.create_presentation(theme="moon")\n\n'
105+
'self.create_presentation(theme="black")\n\n'
106+
'self.create_presentation(theme="night")\n\n'
107+
'self.create_presentation(theme="beige")\n\n'
108+
'self.create_presentation(theme="league")'))
109+
self.add_slide(
110+
'<h2><b>The End</b></h2>',
111+
image="https://seleniumbase.io/img/sb_logo_10.png")
112+
self.begin_presentation(filename="presenter.html", interval=0)

examples/test_demo_site.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def test_demo_site(self):
9494
# Assert exact text
9595
self.assert_exact_text("Demo Page", "h1")
9696

97-
# Assert no broken links
98-
self.assert_no_404_errors()
97+
# Assert no broken links (Can be slow if many links)
98+
# self.assert_no_404_errors()
9999

100-
# Assert no JavaScript errors
100+
# Assert no JavaScript errors (Can also detect 404s)
101101
self.assert_no_js_errors()

help_docs/method_summary.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,14 @@ self.add_meta_tag(http_equiv=None, content=None)
356356

357357
############
358358

359-
self.create_presentation(name=None, show_notes=True)
359+
self.create_presentation(name=None, theme="default", show_notes=True)
360360

361-
self.add_slide(content=None, image=None, code=None, iframe=None, notes=None, name=None)
361+
self.add_slide(content=None, image=None, code=None, iframe=None,
362+
content2=None, notes=None, name=None)
362363

363-
self.save_presentation(filename="my_presentation.html", name=None)
364+
self.save_presentation(name=None, filename=None, interval=0)
364365

365-
self.begin_presentation(filename="my_presentation.html", name=None)
366+
self.begin_presentation(name=None, filename=None, interval=0)
366367

367368
############
368369

0 commit comments

Comments
 (0)