Skip to content

Save exported website tours to the "tours_exported" folder #295

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 7 commits into from
Mar 12, 2019
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ archived_reports
html_report.html
report.html

# Tours
tours_exported

# Other
selenium-server-standalone.jar
proxy.zip
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,9 @@ self.get_page_source() # This method returns the current page source.
Ex:
```python
source = self.get_page_source()
first_image_open_tag = source.find('<img>')
first_image_close_tag = source.find'</img>', first_image_open_tag)
everything_inside_first_image_tags = source[first_image_open_tag+len('<img>'):first_image_close_tag]
head_open_tag = source.find('<head>')
head_close_tag = source.find('</head>', head_open_tag)
everything_inside_head = source[head_open_tag+len('<head>'):head_close_tag]
```

#### Clicking
Expand Down
1 change: 1 addition & 0 deletions examples/tour_examples/bootstrap_google_tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ def test_google_tour(self):
self.add_tour_step(
"Thanks for trying out SeleniumBase Tours!",
title="End of Guided Tour")
self.export_tour(filename="bootstrap_google_maps_tour.js")
self.play_tour()
1 change: 1 addition & 0 deletions examples/tour_examples/google_tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ def test_google_tour(self):
self.add_tour_step(
"Thanks for trying out SeleniumBase Tours!",
title="End of Guided Tour")
self.export_tour()
self.play_tour()
1 change: 1 addition & 0 deletions examples/tour_examples/hopscotch_google_tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ def test_google_tour(self):
self.add_tour_step(
"Thanks for trying out SeleniumBase Tours!",
title="End of Guided Tour")
self.export_tour(filename="hopscotch_google_maps_tour.js")
self.play_tour()
1 change: 1 addition & 0 deletions examples/tour_examples/introjs_google_tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ def test_google_tour(self):
self.add_tour_step(
"Thanks for trying out SeleniumBase Tours!",
title="End of Guided Tour")
self.export_tour(filename="introjs_google_maps_tour.js")
self.play_tour()
1 change: 1 addition & 0 deletions examples/tour_examples/shepherd_google_tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ def test_google_tour(self):
self.add_tour_step(
"Thanks for trying out SeleniumBase Tours!",
title="End of Guided Tour", theme="light")
self.export_tour(filename="shepherd_google_maps_tour.js")
self.play_tour()
1 change: 1 addition & 0 deletions examples/tour_examples/xkcd_tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ def test_basic(self):
self.add_tour_step("This selects a random comic.", 'a[href*="random"]')
self.add_tour_step("Thanks for taking this tour!")
# self.export_tour() # Use this to export the tour as [my_tour.js]
self.export_tour(filename="xkcd_tour.js") # You can customize the name
self.play_tour()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ beautifulsoup4>=4.6.0
colorama==0.4.1
pyotp>=2.2.7
boto>=2.49.0
flake8==3.7.6
flake8==3.7.7
PyVirtualDisplay==0.2.1
-e .
4 changes: 2 additions & 2 deletions seleniumbase/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
BASIC_INFO_NAME = "basic_test_info.txt"
PAGE_SOURCE_NAME = "page_source.html"

# Default names for folders and files saved when reports are turned on.
# Usage: "--report" and "--with-testing_base" together. (NOSETESTS only)
# Default names for files and folders saved when using nosetests reports.
# Usage: "--report". (NOSETESTS only)
LATEST_REPORT_DIR = "latest_report"
REPORT_ARCHIVE_DIR = "archived_reports"
HTML_REPORT = "report.html"
Expand Down
16 changes: 14 additions & 2 deletions seleniumbase/core/tour_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module contains methods for running website tours.
These helper methods SHOULD NOT be called directly from tests.
"""
import os
import re
import time
from selenium.webdriver.common.by import By
Expand All @@ -11,6 +12,8 @@
from seleniumbase.fixtures import js_utils
from seleniumbase.fixtures import page_actions

EXPORTED_TOURS_FOLDER = "tours_exported"


def raise_unable_to_load_jquery_exception(driver):
""" The most-likely reason for jQuery not loading on web pages. """
Expand Down Expand Up @@ -790,8 +793,17 @@ def export_tour(tour_steps, name=None, filename="my_tour.js", url=None):
else:
pass

exported_tours_folder = EXPORTED_TOURS_FOLDER
if exported_tours_folder.endswith("/"):
exported_tours_folder = exported_tours_folder[:-1]
if not os.path.exists(exported_tours_folder):
try:
os.makedirs(exported_tours_folder)
except Exception:
pass
import codecs
out_file = codecs.open(filename, "w+")
file_path = exported_tours_folder + "/" + filename
out_file = codecs.open(file_path, "w+")
out_file.writelines(instructions)
out_file.close()
print('\n>>> [%s] was saved!\n' % filename)
print('\n>>> [%s] was saved!\n' % file_path)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setup(
name='seleniumbase',
version='1.21.3',
version='1.21.4',
description='Reliable Browser Automation & Testing Framework',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down