From 60466df20f1c3b6f533478a7625f1b1ab06fa51d Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Tue, 12 Mar 2019 00:40:39 -0400 Subject: [PATCH 1/7] Exported tours get saved in the "tours_exported" folder --- seleniumbase/core/tour_helper.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/seleniumbase/core/tour_helper.py b/seleniumbase/core/tour_helper.py index c784f0dca9e..e102688d29d 100755 --- a/seleniumbase/core/tour_helper.py +++ b/seleniumbase/core/tour_helper.py @@ -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 @@ -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. """ @@ -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) From 6150e7b8d11a411773a30ba4435834421d958e94 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Tue, 12 Mar 2019 00:43:51 -0400 Subject: [PATCH 2/7] Update tour examples --- examples/tour_examples/bootstrap_google_tour.py | 1 + examples/tour_examples/google_tour.py | 1 + examples/tour_examples/hopscotch_google_tour.py | 1 + examples/tour_examples/introjs_google_tour.py | 1 + examples/tour_examples/shepherd_google_tour.py | 1 + examples/tour_examples/xkcd_tour.py | 1 + 6 files changed, 6 insertions(+) diff --git a/examples/tour_examples/bootstrap_google_tour.py b/examples/tour_examples/bootstrap_google_tour.py index ba7eb724133..f59bfa44a9c 100755 --- a/examples/tour_examples/bootstrap_google_tour.py +++ b/examples/tour_examples/bootstrap_google_tour.py @@ -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() diff --git a/examples/tour_examples/google_tour.py b/examples/tour_examples/google_tour.py index 1ecfd18c2d6..66cd3dd5e80 100755 --- a/examples/tour_examples/google_tour.py +++ b/examples/tour_examples/google_tour.py @@ -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() diff --git a/examples/tour_examples/hopscotch_google_tour.py b/examples/tour_examples/hopscotch_google_tour.py index 5e269623bf6..35a7bca83ce 100755 --- a/examples/tour_examples/hopscotch_google_tour.py +++ b/examples/tour_examples/hopscotch_google_tour.py @@ -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() diff --git a/examples/tour_examples/introjs_google_tour.py b/examples/tour_examples/introjs_google_tour.py index 4a09f674a28..71aac272548 100755 --- a/examples/tour_examples/introjs_google_tour.py +++ b/examples/tour_examples/introjs_google_tour.py @@ -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() diff --git a/examples/tour_examples/shepherd_google_tour.py b/examples/tour_examples/shepherd_google_tour.py index 9db0844048b..fe4bb92713a 100755 --- a/examples/tour_examples/shepherd_google_tour.py +++ b/examples/tour_examples/shepherd_google_tour.py @@ -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() diff --git a/examples/tour_examples/xkcd_tour.py b/examples/tour_examples/xkcd_tour.py index 73b5c36e83d..c4a534f84c0 100755 --- a/examples/tour_examples/xkcd_tour.py +++ b/examples/tour_examples/xkcd_tour.py @@ -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() From baebade83aa95d6e2770d513e29b0017d6d57423 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Tue, 12 Mar 2019 00:49:36 -0400 Subject: [PATCH 3/7] Update comments in settings.py --- seleniumbase/config/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seleniumbase/config/settings.py b/seleniumbase/config/settings.py index c056c2186db..567cd0fbd0a 100755 --- a/seleniumbase/config/settings.py +++ b/seleniumbase/config/settings.py @@ -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" From 631cbeea34f9cc041a13716427b5b06a793e5d0c Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Tue, 12 Mar 2019 00:51:05 -0400 Subject: [PATCH 4/7] Add the "tours_exported" folder to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 9ee043820dd..9726bc1ffe0 100644 --- a/.gitignore +++ b/.gitignore @@ -62,6 +62,9 @@ archived_reports html_report.html report.html +# Tours +tours_exported + # Other selenium-server-standalone.jar proxy.zip From 8b9a01d1ef96e5375f8f32ba5fb55fc07e4e6a74 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Tue, 12 Mar 2019 00:52:48 -0400 Subject: [PATCH 5/7] Update flake8 version to 3.7.7 in requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 442b587aa7d..85820fa0f08 100755 --- a/requirements.txt +++ b/requirements.txt @@ -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 . From 2bd6e1ba06e7b143c687e94b24bd51205bb76ed4 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Tue, 12 Mar 2019 00:53:01 -0400 Subject: [PATCH 6/7] Update the ReadMe --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a5ae62ca496..aed06b6bc17 100755 --- a/README.md +++ b/README.md @@ -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('') -first_image_close_tag = source.find'', first_image_open_tag) -everything_inside_first_image_tags = source[first_image_open_tag+len(''):first_image_close_tag] +head_open_tag = source.find('') +head_close_tag = source.find('', head_open_tag) +everything_inside_head = source[head_open_tag+len(''):head_close_tag] ``` #### Clicking From f221fbf26b4e4301d05239e8e072eecff6b01006 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Tue, 12 Mar 2019 00:58:02 -0400 Subject: [PATCH 7/7] Version 1.21.4 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b96de367d0e..0274b615558 100755 --- a/setup.py +++ b/setup.py @@ -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',