Skip to content

Commit 0cc6043

Browse files
committed
Update SeleniumBase Presenter
1 parent b56e01b commit 0cc6043

File tree

4 files changed

+237
-93
lines changed

4 files changed

+237
-93
lines changed

examples/presenter/ReadMe.md

Lines changed: 70 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
SeleniumBase Presenter allows you to create an HTML presentation with only a few lines of 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+
<img width="500" src="https://seleniumbase.io/other/presenter.gif" title="Screenshot"><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>')
97+
self.add_slide(
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>')
81103
self.add_slide(
82-
"<h2>Welcome!</h2>"
83-
"<h4>Enjoy the Presentation!</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>')
84113
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>')
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+
)
88126
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>')
127+
'<h3>Add <b>images</b> to slides:</h3>',
128+
image="https://seleniumbase.io/other/seagulls.jpg")
94129
self.add_slide(
95-
"<h3>You can display code:</h3>",
130+
'<h3>Add <b>code</b> to slides:</h3>',
96131
code=(
97132
'from seleniumbase import BaseCase\n\n'
98133
'class MyTestClass(BaseCase):\n\n'
@@ -109,24 +144,29 @@ class MyPresenterClass(BaseCase):
109144
' self.click_link_text("About")\n'
110145
' self.assert_exact_text("xkcd.com", "h2")\n'))
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")\n'))
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>Include <b>notes</b> with slides:</h3><br />',
160+
code=('self.add_slide("[Your HTML goes here]",\n'
161+
' code="[Your software code goes here]",\n'
162+
' content2="[Additional HTML goes here]",\n'
163+
' notes="[Attached speaker notes go here]")'),
164+
content2='<h4>(Example Presenter Usage)</h4>',
165+
notes='<h2><ul><li>Note A!<li>Note B!<li>Note C!<li>Note D!</h2>')
125166
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()
167+
'<h2><b>The End</b></h2>',
168+
image="https://seleniumbase.io/img/sb_logo_10.png")
169+
self.begin_presentation(filename="my_presentation.html", interval=0)
130170
```
131171

132172
#### 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 +180,7 @@ pytest my_presentation.py
140180
If you want to save the presentation you created as an HTML file, use:
141181

142182
```python
143-
self.save_presentation(filename="my_presentation.html", name=None)
183+
self.save_presentation(filename="my_presentation.html")
144184
```
145185

146186
Presentations automatically get saved when calling:

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)