Skip to content

Commit 0dad07d

Browse files
authored
Merge pull request #606 from seleniumbase/fix-presenter-notes
Fix the "show_notes" feature of SeleniumBase Presenter
2 parents d2d7875 + d22899f commit 0dad07d

File tree

8 files changed

+51
-29
lines changed

8 files changed

+51
-29
lines changed

examples/presenter/ReadMe.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pytest my_presentation.py
2121
### Creating a new presentation:
2222

2323
```python
24-
self.create_presentation(name=None, theme="serif", show_notes=True)
24+
self.create_presentation(name=None, theme="serif")
2525
""" Creates a Reveal-JS presentation that you can add slides to.
2626
@Params
2727
name - If creating multiple presentations at the same time,
@@ -30,8 +30,6 @@ self.create_presentation(name=None, theme="serif", show_notes=True)
3030
Valid themes: "serif" (default), "sky", "white", "black",
3131
"simple", "league", "moon", "night",
3232
"beige", "blood", and "solarized".
33-
show_notes - When set to True, the Notes feature becomes enabled,
34-
which allows presenters to see notes next to slides.
3533
"""
3634
```
3735

@@ -64,13 +62,16 @@ self.add_slide(content=None, image=None, code=None, iframe=None,
6462
### Running a presentation:
6563

6664
```python
67-
self.begin_presentation(filename="my_presentation.html", interval=0)
65+
self.begin_presentation(
66+
filename="my_presentation.html", show_notes=True, interval=0)
6867
""" Begin a Reveal-JS Presentation in the web browser.
6968
@Params
7069
name - If creating multiple presentations at the same time,
7170
use this to select the one you wish to add slides to.
7271
filename - The name of the HTML file that you wish to
7372
save the presentation to. (filename must end in ".html")
73+
show_notes - When set to True, the Notes feature becomes enabled,
74+
which allows presenters to see notes next to slides.
7475
interval - The delay time between autoplaying slides. (in seconds)
7576
If set to 0 (default), autoplay is disabled.
7677
"""
@@ -161,7 +162,7 @@ class MyPresenterClass(BaseCase):
161162
'from seleniumbase import BaseCase\n\n'
162163
'class MyPresenterClass(BaseCase):\n\n'
163164
' def test_presenter(self):\n'
164-
' self.create_presentation()\n'
165+
' self.create_presentation(theme="serif")\n'
165166
' self.add_slide("Welcome to Presenter!")\n'
166167
' self.add_slide(\n'
167168
' "Add code to slides:",\n'
@@ -170,7 +171,8 @@ class MyPresenterClass(BaseCase):
170171
' "class MyPresenterClass(BaseCase):\\n\\n"\n'
171172
' " def test_presenter(self):\\n"\n'
172173
' " self.create_presentation()\\n"))\n'
173-
' self.begin_presentation(filename="demo.html")'))
174+
' self.begin_presentation(\n'
175+
' filename="demo.html", show_notes=True)'))
174176
self.add_slide(
175177
'<h3>Include <b>notes</b> with slides:</h3><br />',
176178
code=('self.add_slide("[Your HTML goes here]",\n'
@@ -195,7 +197,8 @@ class MyPresenterClass(BaseCase):
195197
self.add_slide(
196198
'<h2><b>The End</b></h2>',
197199
image="https://seleniumbase.io/img/sb_logo_10.png")
198-
self.begin_presentation(filename="presenter.html", interval=0)
200+
self.begin_presentation(
201+
filename="presenter.html", show_notes=True, interval=0)
199202
```
200203

201204
#### 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:
@@ -209,10 +212,10 @@ pytest my_presentation.py
209212
If you want to save the presentation you created as an HTML file, use:
210213

211214
```python
212-
self.save_presentation(filename="my_presentation.html")
215+
self.save_presentation(filename="my_presentation.html", show_notes=True)
213216
```
214217

215218
Presentations automatically get saved when calling:
216219
```python
217-
self.begin_presentation()
220+
self.begin_presentation(show_notes=True)
218221
```

examples/presenter/my_presentation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_presenter(self):
7575
'from seleniumbase import BaseCase\n\n'
7676
'class MyPresenterClass(BaseCase):\n\n'
7777
' def test_presenter(self):\n'
78-
' self.create_presentation()\n'
78+
' self.create_presentation(theme="serif")\n'
7979
' self.add_slide("Welcome to Presenter!")\n'
8080
' self.add_slide(\n'
8181
' "Add code to slides:",\n'
@@ -84,7 +84,8 @@ def test_presenter(self):
8484
' "class MyPresenterClass(BaseCase):\\n\\n"\n'
8585
' " def test_presenter(self):\\n"\n'
8686
' " self.create_presentation()\\n"))\n'
87-
' self.begin_presentation(filename="demo.html")'))
87+
' self.begin_presentation(\n'
88+
' filename="demo.html", show_notes=True)'))
8889
self.add_slide(
8990
'<h3>Include <b>notes</b> with slides:</h3><br />',
9091
code=('self.add_slide("[Your HTML goes here]",\n'
@@ -109,4 +110,5 @@ def test_presenter(self):
109110
self.add_slide(
110111
'<h2><b>The End</b></h2>',
111112
image="https://seleniumbase.io/img/sb_logo_10.png")
112-
self.begin_presentation(filename="presenter.html", interval=0)
113+
self.begin_presentation(
114+
filename="presenter.html", show_notes=True, interval=0)

help_docs/method_summary.md

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

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

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

361361
self.add_slide(content=None, image=None, code=None, iframe=None,
362362
content2=None, notes=None, name=None)
363363

364-
self.save_presentation(name=None, filename=None, interval=0)
364+
self.save_presentation(name=None, filename=None, show_notes=True, interval=0)
365365

366-
self.begin_presentation(name=None, filename=None, interval=0)
366+
self.begin_presentation(name=None, filename=None, show_notes=True, interval=0)
367367

368368
############
369369

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ coverage==5.1
4242
pyotp==2.3.0
4343
boto==2.49.0
4444
cffi==1.14.0
45-
rich==3.0.0;python_version>="3.6" and python_version<"4.0"
45+
rich==3.0.1;python_version>="3.6" and python_version<"4.0"
4646
flake8==3.7.9;python_version<"3.5"
4747
flake8==3.8.3;python_version>="3.5"
4848
pyflakes==2.1.1;python_version<"3.5"

seleniumbase/common/obfuscate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def main():
3030
print("\nInside a test, use the following to decrypt it:\n")
3131
time.sleep(0.2)
3232
print(" from seleniumbase import encryption")
33-
print(" encryption.decrypt('%s')" % encrypted_password)
33+
print(' encryption.decrypt("%s")' % encrypted_password)
3434
time.sleep(0.2)
3535
except KeyboardInterrupt:
3636
print("\nExiting...\n")

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,21 @@ def main():
5858
'Directory name must not include slashes ("/", "\\")!')
5959
elif os.path.exists(os.getcwd() + '/' + dir_name):
6060
error_msg = (
61-
'Directory "%s" already exists in the current path!\n'
62-
'' % dir_name)
61+
'Directory "%s" already exists in the current path!' % dir_name)
6362
if error_msg:
6463
error_msg = c5 + error_msg + cr
6564
invalid_run_command(error_msg)
6665

6766
os.mkdir(dir_name)
6867

68+
data = []
69+
data.append("seleniumbase")
70+
data.append("")
71+
file_path = "%s/%s" % (dir_name, "requirements.txt")
72+
file = codecs.open(file_path, "w+", "utf-8")
73+
file.writelines("\r\n".join(data))
74+
file.close()
75+
6976
data = []
7077
data.append("[pytest]")
7178
data.append("addopts = --capture=no --ignore conftest.py "

seleniumbase/fixtures/base_case.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,7 +3151,7 @@ def add_meta_tag(self, http_equiv=None, content=None):
31513151

31523152
############
31533153

3154-
def create_presentation(self, name=None, theme="default", show_notes=True):
3154+
def create_presentation(self, name=None, theme="default"):
31553155
""" Creates a Reveal-JS presentation that you can add slides to.
31563156
@Params
31573157
name - If creating multiple presentations at the same time,
@@ -3160,8 +3160,6 @@ def create_presentation(self, name=None, theme="default", show_notes=True):
31603160
Valid themes: "serif" (default), "sky", "white", "black",
31613161
"simple", "league", "moon", "night",
31623162
"beige", "blood", and "solarized".
3163-
show_notes - When set to True, the Notes feature becomes enabled,
3164-
which allows presenters to see notes next to slides.
31653163
"""
31663164
if not name:
31673165
name = "default"
@@ -3242,7 +3240,7 @@ def add_slide(self, content=None, image=None, code=None, iframe=None,
32423240
name = "default"
32433241
if name not in self._presentation_slides:
32443242
# Create a presentation if it doesn't already exist
3245-
self.create_presentation(name=name, show_notes=True)
3243+
self.create_presentation(name=name)
32463244
if not content:
32473245
content = ""
32483246
if not content2:
@@ -3273,13 +3271,16 @@ def add_slide(self, content=None, image=None, code=None, iframe=None,
32733271

32743272
self._presentation_slides[name].append(html)
32753273

3276-
def save_presentation(self, name=None, filename=None, interval=0):
3274+
def save_presentation(
3275+
self, name=None, filename=None, show_notes=True, interval=0):
32773276
""" Saves a Reveal-JS Presentation to a file for later use.
32783277
@Params
32793278
name - If creating multiple presentations at the same time,
32803279
use this to select the one you wish to add slides to.
32813280
filename - The name of the HTML file that you wish to
32823281
save the presentation to. (filename must end in ".html")
3282+
show_notes - When set to True, the Notes feature becomes enabled,
3283+
which allows presenters to see notes next to slides.
32833284
interval - The delay time between autoplaying slides. (in seconds)
32843285
If set to 0 (default), autoplay is disabled.
32853286
"""
@@ -3300,6 +3301,10 @@ def save_presentation(self, name=None, filename=None, interval=0):
33003301
raise Exception('The "interval" cannot be a negative number!')
33013302
interval_ms = float(interval) * 1000.0
33023303

3304+
show_notes_str = "false"
3305+
if show_notes:
3306+
show_notes_str = "true"
3307+
33033308
the_html = ""
33043309
for slide in self._presentation_slides[name]:
33053310
the_html += slide
@@ -3310,13 +3315,14 @@ def save_presentation(self, name=None, filename=None, interval=0):
33103315
'<script src="%s"></script>\n'
33113316
'<script src="%s"></script>\n'
33123317
'<script>Reveal.initialize('
3313-
'{showNotes: true, slideNumber: true, '
3318+
'{showNotes: %s, slideNumber: true, '
33143319
'autoSlide: %s,});'
33153320
'</script>\n'
33163321
'</body>\n'
33173322
'</html>\n'
33183323
'' % (constants.Reveal.MIN_JS,
33193324
constants.PrettifyJS.RUN_PRETTIFY_JS,
3325+
show_notes_str,
33203326
interval_ms))
33213327

33223328
saved_presentations_folder = constants.Presentations.SAVED_FOLDER
@@ -3334,13 +3340,16 @@ def save_presentation(self, name=None, filename=None, interval=0):
33343340
print('\n>>> [%s] was saved!\n' % file_path)
33353341
return file_path
33363342

3337-
def begin_presentation(self, name=None, filename=None, interval=0):
3343+
def begin_presentation(
3344+
self, name=None, filename=None, show_notes=True, interval=0):
33383345
""" Begin a Reveal-JS Presentation in the web browser.
33393346
@Params
33403347
name - If creating multiple presentations at the same time,
33413348
use this to select the one you wish to add slides to.
33423349
filename - The name of the HTML file that you wish to
33433350
save the presentation to. (filename must end in ".html")
3351+
show_notes - When set to True, the Notes feature becomes enabled,
3352+
which allows presenters to see notes next to slides.
33443353
interval - The delay time between autoplaying slides. (in seconds)
33453354
If set to 0 (default), autoplay is disabled.
33463355
"""
@@ -3366,7 +3375,8 @@ def begin_presentation(self, name=None, filename=None, interval=0):
33663375
'<p class="End_Presentation_Now"> </p>\n</section>\n')
33673376
self._presentation_slides[name].append(end_slide)
33683377
file_path = self.save_presentation(
3369-
name=name, filename=filename, interval=interval)
3378+
name=name, filename=filename,
3379+
show_notes=show_notes, interval=interval)
33703380
self._presentation_slides[name].pop()
33713381

33723382
self.open_html_file(file_path)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
setup(
5656
name='seleniumbase',
57-
version='1.42.1',
57+
version='1.42.2',
5858
description='Fast, Easy, and Reliable Browser Automation & Testing.',
5959
long_description=long_description,
6060
long_description_content_type='text/markdown',
@@ -134,7 +134,7 @@
134134
'pyotp==2.3.0',
135135
'boto==2.49.0',
136136
'cffi==1.14.0',
137-
'rich==3.0.0;python_version>="3.6" and python_version<"4.0"',
137+
'rich==3.0.1;python_version>="3.6" and python_version<"4.0"',
138138
'flake8==3.7.9;python_version<"3.5"',
139139
'flake8==3.8.3;python_version>="3.5"',
140140
'pyflakes==2.1.1;python_version<"3.5"',

0 commit comments

Comments
 (0)