Skip to content

Fix the "show_notes" feature of SeleniumBase Presenter #606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions examples/presenter/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pytest my_presentation.py
### Creating a new presentation:

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

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

```python
self.begin_presentation(filename="my_presentation.html", interval=0)
self.begin_presentation(
filename="my_presentation.html", show_notes=True, interval=0)
""" Begin a Reveal-JS Presentation in the web browser.
@Params
name - If creating multiple presentations at the same time,
use this to select the one you wish to add slides to.
filename - The name of the HTML file that you wish to
save the presentation to. (filename must end in ".html")
show_notes - When set to True, the Notes feature becomes enabled,
which allows presenters to see notes next to slides.
interval - The delay time between autoplaying slides. (in seconds)
If set to 0 (default), autoplay is disabled.
"""
Expand Down Expand Up @@ -161,7 +162,7 @@ class MyPresenterClass(BaseCase):
'from seleniumbase import BaseCase\n\n'
'class MyPresenterClass(BaseCase):\n\n'
' def test_presenter(self):\n'
' self.create_presentation()\n'
' self.create_presentation(theme="serif")\n'
' self.add_slide("Welcome to Presenter!")\n'
' self.add_slide(\n'
' "Add code to slides:",\n'
Expand All @@ -170,7 +171,8 @@ class MyPresenterClass(BaseCase):
' "class MyPresenterClass(BaseCase):\\n\\n"\n'
' " def test_presenter(self):\\n"\n'
' " self.create_presentation()\\n"))\n'
' self.begin_presentation(filename="demo.html")'))
' self.begin_presentation(\n'
' filename="demo.html", show_notes=True)'))
self.add_slide(
'<h3>Include <b>notes</b> with slides:</h3><br />',
code=('self.add_slide("[Your HTML goes here]",\n'
Expand All @@ -195,7 +197,8 @@ class MyPresenterClass(BaseCase):
self.add_slide(
'<h2><b>The End</b></h2>',
image="https://seleniumbase.io/img/sb_logo_10.png")
self.begin_presentation(filename="presenter.html", interval=0)
self.begin_presentation(
filename="presenter.html", show_notes=True, interval=0)
```

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

```python
self.save_presentation(filename="my_presentation.html")
self.save_presentation(filename="my_presentation.html", show_notes=True)
```

Presentations automatically get saved when calling:
```python
self.begin_presentation()
self.begin_presentation(show_notes=True)
```
8 changes: 5 additions & 3 deletions examples/presenter/my_presentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_presenter(self):
'from seleniumbase import BaseCase\n\n'
'class MyPresenterClass(BaseCase):\n\n'
' def test_presenter(self):\n'
' self.create_presentation()\n'
' self.create_presentation(theme="serif")\n'
' self.add_slide("Welcome to Presenter!")\n'
' self.add_slide(\n'
' "Add code to slides:",\n'
Expand All @@ -84,7 +84,8 @@ def test_presenter(self):
' "class MyPresenterClass(BaseCase):\\n\\n"\n'
' " def test_presenter(self):\\n"\n'
' " self.create_presentation()\\n"))\n'
' self.begin_presentation(filename="demo.html")'))
' self.begin_presentation(\n'
' filename="demo.html", show_notes=True)'))
self.add_slide(
'<h3>Include <b>notes</b> with slides:</h3><br />',
code=('self.add_slide("[Your HTML goes here]",\n'
Expand All @@ -109,4 +110,5 @@ def test_presenter(self):
self.add_slide(
'<h2><b>The End</b></h2>',
image="https://seleniumbase.io/img/sb_logo_10.png")
self.begin_presentation(filename="presenter.html", interval=0)
self.begin_presentation(
filename="presenter.html", show_notes=True, interval=0)
6 changes: 3 additions & 3 deletions help_docs/method_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,14 @@ self.add_meta_tag(http_equiv=None, content=None)

############

self.create_presentation(name=None, theme="default", show_notes=True)
self.create_presentation(name=None, theme="default")

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

self.save_presentation(name=None, filename=None, interval=0)
self.save_presentation(name=None, filename=None, show_notes=True, interval=0)
Copy link
Contributor

@hiqqs hiqqs Jul 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this hardcode showNotes to true on save? should be None? maybe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooooo nvm i see its just the help docs 👍


self.begin_presentation(name=None, filename=None, interval=0)
self.begin_presentation(name=None, filename=None, show_notes=True, interval=0)

############

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ coverage==5.1
pyotp==2.3.0
boto==2.49.0
cffi==1.14.0
rich==3.0.0;python_version>="3.6" and python_version<"4.0"
rich==3.0.1;python_version>="3.6" and python_version<"4.0"
flake8==3.7.9;python_version<"3.5"
flake8==3.8.3;python_version>="3.5"
pyflakes==2.1.1;python_version<"3.5"
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/common/obfuscate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def main():
print("\nInside a test, use the following to decrypt it:\n")
time.sleep(0.2)
print(" from seleniumbase import encryption")
print(" encryption.decrypt('%s')" % encrypted_password)
print(' encryption.decrypt("%s")' % encrypted_password)
time.sleep(0.2)
except KeyboardInterrupt:
print("\nExiting...\n")
Expand Down
11 changes: 9 additions & 2 deletions seleniumbase/console_scripts/sb_mkdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,21 @@ def main():
'Directory name must not include slashes ("/", "\\")!')
elif os.path.exists(os.getcwd() + '/' + dir_name):
error_msg = (
'Directory "%s" already exists in the current path!\n'
'' % dir_name)
'Directory "%s" already exists in the current path!' % dir_name)
if error_msg:
error_msg = c5 + error_msg + cr
invalid_run_command(error_msg)

os.mkdir(dir_name)

data = []
data.append("seleniumbase")
data.append("")
file_path = "%s/%s" % (dir_name, "requirements.txt")
file = codecs.open(file_path, "w+", "utf-8")
file.writelines("\r\n".join(data))
file.close()

data = []
data.append("[pytest]")
data.append("addopts = --capture=no --ignore conftest.py "
Expand Down
26 changes: 18 additions & 8 deletions seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -3151,7 +3151,7 @@ def add_meta_tag(self, http_equiv=None, content=None):

############

def create_presentation(self, name=None, theme="default", show_notes=True):
def create_presentation(self, name=None, theme="default"):
""" Creates a Reveal-JS presentation that you can add slides to.
@Params
name - If creating multiple presentations at the same time,
Expand All @@ -3160,8 +3160,6 @@ def create_presentation(self, name=None, theme="default", show_notes=True):
Valid themes: "serif" (default), "sky", "white", "black",
"simple", "league", "moon", "night",
"beige", "blood", and "solarized".
show_notes - When set to True, the Notes feature becomes enabled,
which allows presenters to see notes next to slides.
"""
if not name:
name = "default"
Expand Down Expand Up @@ -3242,7 +3240,7 @@ def add_slide(self, content=None, image=None, code=None, iframe=None,
name = "default"
if name not in self._presentation_slides:
# Create a presentation if it doesn't already exist
self.create_presentation(name=name, show_notes=True)
self.create_presentation(name=name)
if not content:
content = ""
if not content2:
Expand Down Expand Up @@ -3273,13 +3271,16 @@ def add_slide(self, content=None, image=None, code=None, iframe=None,

self._presentation_slides[name].append(html)

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

show_notes_str = "false"
if show_notes:
show_notes_str = "true"

the_html = ""
for slide in self._presentation_slides[name]:
the_html += slide
Expand All @@ -3310,13 +3315,14 @@ def save_presentation(self, name=None, filename=None, interval=0):
'<script src="%s"></script>\n'
'<script src="%s"></script>\n'
'<script>Reveal.initialize('
'{showNotes: true, slideNumber: true, '
'{showNotes: %s, slideNumber: true, '
'autoSlide: %s,});'
'</script>\n'
'</body>\n'
'</html>\n'
'' % (constants.Reveal.MIN_JS,
constants.PrettifyJS.RUN_PRETTIFY_JS,
show_notes_str,
interval_ms))

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

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

self.open_html_file(file_path)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

setup(
name='seleniumbase',
version='1.42.1',
version='1.42.2',
description='Fast, Easy, and Reliable Browser Automation & Testing.',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down Expand Up @@ -134,7 +134,7 @@
'pyotp==2.3.0',
'boto==2.49.0',
'cffi==1.14.0',
'rich==3.0.0;python_version>="3.6" and python_version<"4.0"',
'rich==3.0.1;python_version>="3.6" and python_version<"4.0"',
'flake8==3.7.9;python_version<"3.5"',
'flake8==3.8.3;python_version>="3.5"',
'pyflakes==2.1.1;python_version<"3.5"',
Expand Down