@@ -76,12 +76,12 @@ def __init__(self, *args, **kwargs):
76
76
self .environment = None
77
77
self .__last_url_of_delayed_assert = "data:,"
78
78
self .__last_page_load_url = "data:,"
79
- self ._page_check_count = 0
80
- self ._page_check_failures = []
81
- self ._html_report_extra = []
79
+ self .__page_check_count = 0
80
+ self .__page_check_failures = []
81
+ self ._html_report_extra = [] # (Used by pytest_plugin.py)
82
82
self ._default_driver = None
83
83
self ._drivers_list = []
84
- self ._tutorials = {}
84
+ self ._tour_steps = {}
85
85
86
86
def open (self , url ):
87
87
self .__last_page_load_url = None
@@ -951,11 +951,11 @@ def is_shepherd_activated(self):
951
951
return False
952
952
953
953
def create_tour (self , name = None , theme = None ):
954
- """ Creates a tutorial tour for a website.
954
+ """ Creates a tour for a website.
955
955
@Params
956
956
name - If creating multiple tours, use this to select the
957
957
tour you wish to add steps to.
958
- theme - Sets the default theme for the tutorial tour.
958
+ theme - Sets the default theme for the tour.
959
959
Choose from "arrows", "dark", "default", "square", and
960
960
"square-dark". ("arrows" is used if None is selected.)
961
961
"""
@@ -975,19 +975,19 @@ def create_tour(self, name=None, theme=None):
975
975
elif theme == "square-dark" :
976
976
shepherd_theme = "shepherd-theme-square-dark"
977
977
978
- tutorial = ("""let tour = new Shepherd.Tour({
978
+ new_tour = ("""let tour = new Shepherd.Tour({
979
979
defaults: {
980
980
classes: '%s',
981
981
scrollTo: true
982
982
}
983
983
});""" % shepherd_theme )
984
984
985
- self ._tutorials [name ] = []
986
- self ._tutorials [name ].append (tutorial )
985
+ self ._tour_steps [name ] = []
986
+ self ._tour_steps [name ].append (new_tour )
987
987
988
988
def add_tour_step (self , message , selector = None , name = None ,
989
989
title = None , theme = None , alignment = None ):
990
- """ Allows the user to add tutorial tour steps for a website.
990
+ """ Allows the user to add tour steps for a website.
991
991
@Params
992
992
message - The message to display.
993
993
selector - The CSS Selector of the Element to attach to.
@@ -1005,7 +1005,7 @@ def add_tour_step(self, message, selector=None, name=None,
1005
1005
1006
1006
if not name :
1007
1007
name = "default"
1008
- if name not in self ._tutorials :
1008
+ if name not in self ._tour_steps :
1009
1009
self .create_tour (name = name )
1010
1010
1011
1011
if not title :
@@ -1030,7 +1030,7 @@ def add_tour_step(self, message, selector=None, name=None,
1030
1030
else :
1031
1031
shepherd_base_theme = re .search (
1032
1032
"[\S\s]+classes: '([\S\s]+)',[\S\s]+" ,
1033
- self ._tutorials [name ][0 ]).group (1 )
1033
+ self ._tour_steps [name ][0 ]).group (1 )
1034
1034
shepherd_theme = shepherd_base_theme
1035
1035
1036
1036
if not alignment or (
@@ -1050,35 +1050,35 @@ def add_tour_step(self, message, selector=None, name=None,
1050
1050
});""" % (
1051
1051
name , title , shepherd_classes , message , selector , alignment ))
1052
1052
1053
- self ._tutorials [name ].append (step )
1053
+ self ._tour_steps [name ].append (step )
1054
1054
1055
1055
def play_tour (self , name = None ):
1056
- """ Plays a tutorial tour on the current website.
1056
+ """ Plays a tour on the current website.
1057
1057
@Params
1058
1058
name - If creating multiple tours, use this to select the
1059
1059
tour you wish to play.
1060
1060
"""
1061
1061
if self .headless :
1062
- return # Tutorial tours should not run in headless mode.
1062
+ return # Tours should not run in headless mode.
1063
1063
1064
1064
if not name :
1065
1065
name = "default"
1066
- if name not in self ._tutorials :
1066
+ if name not in self ._tour_steps :
1067
1067
raise Exception ("Tour {%s} does not exist!" % name )
1068
1068
1069
1069
instructions = ""
1070
- for tutorial_step in self ._tutorials [name ]:
1071
- instructions += tutorial_step
1070
+ for tour_step in self ._tour_steps [name ]:
1071
+ instructions += tour_step
1072
1072
instructions += "tour.start();"
1073
1073
1074
1074
if not self .is_shepherd_activated ():
1075
1075
self .activate_shepherd ()
1076
1076
1077
- if len (self ._tutorials [name ]) > 1 :
1077
+ if len (self ._tour_steps [name ]) > 1 :
1078
1078
try :
1079
1079
selector = re .search (
1080
1080
"[\S\s]+{element: '([\S\s]+)', on: [\S\s]+" ,
1081
- self ._tutorials [name ][1 ]).group (1 )
1081
+ self ._tour_steps [name ][1 ]).group (1 )
1082
1082
self .__wait_for_css_query_selector (selector )
1083
1083
except Exception :
1084
1084
self .__post_messenger_error_message (
@@ -1091,17 +1091,17 @@ def play_tour(self, name=None):
1091
1091
"" % selector )
1092
1092
1093
1093
self .execute_script (instructions )
1094
- tutorial_on = True
1095
- while tutorial_on :
1094
+ tour_on = True
1095
+ while tour_on :
1096
1096
try :
1097
1097
time .sleep (0.01 )
1098
1098
result = self .execute_script (
1099
1099
"return Shepherd.activeTour.currentStep.isOpen()" )
1100
1100
except Exception :
1101
- tutorial_on = False
1101
+ tour_on = False
1102
1102
result = None
1103
1103
if result :
1104
- tutorial_on = True
1104
+ tour_on = True
1105
1105
else :
1106
1106
try :
1107
1107
time .sleep (0.01 )
@@ -1119,9 +1119,9 @@ def play_tour(self, name=None):
1119
1119
duration = settings .SMALL_TIMEOUT )
1120
1120
time .sleep (0.1 )
1121
1121
self .execute_script ("Shepherd.activeTour.next()" )
1122
- tutorial_on = True
1122
+ tour_on = True
1123
1123
except Exception :
1124
- tutorial_on = False
1124
+ tour_on = False
1125
1125
time .sleep (0.1 )
1126
1126
1127
1127
def __wait_for_css_query_selector (
@@ -1828,8 +1828,8 @@ def pick_select_option_by_text(self, dropdown_selector, option,
1828
1828
if self .timeout_multiplier and timeout == settings .LARGE_TIMEOUT :
1829
1829
timeout = self .__get_new_timeout (timeout )
1830
1830
self .__pick_select_option (dropdown_selector , option ,
1831
- dropdown_by = dropdown_by , option_by = "text" ,
1832
- timeout = timeout )
1831
+ dropdown_by = dropdown_by , option_by = "text" ,
1832
+ timeout = timeout )
1833
1833
1834
1834
def pick_select_option_by_index (self , dropdown_selector , option ,
1835
1835
dropdown_by = By .CSS_SELECTOR ,
@@ -1838,8 +1838,8 @@ def pick_select_option_by_index(self, dropdown_selector, option,
1838
1838
if self .timeout_multiplier and timeout == settings .LARGE_TIMEOUT :
1839
1839
timeout = self .__get_new_timeout (timeout )
1840
1840
self .__pick_select_option (dropdown_selector , option ,
1841
- dropdown_by = dropdown_by , option_by = "index" ,
1842
- timeout = timeout )
1841
+ dropdown_by = dropdown_by , option_by = "index" ,
1842
+ timeout = timeout )
1843
1843
1844
1844
def pick_select_option_by_value (self , dropdown_selector , option ,
1845
1845
dropdown_by = By .CSS_SELECTOR ,
@@ -1848,8 +1848,8 @@ def pick_select_option_by_value(self, dropdown_selector, option,
1848
1848
if self .timeout_multiplier and timeout == settings .LARGE_TIMEOUT :
1849
1849
timeout = self .__get_new_timeout (timeout )
1850
1850
self .__pick_select_option (dropdown_selector , option ,
1851
- dropdown_by = dropdown_by , option_by = "value" ,
1852
- timeout = timeout )
1851
+ dropdown_by = dropdown_by , option_by = "value" ,
1852
+ timeout = timeout )
1853
1853
1854
1854
def generate_referral (self , start_page , destination_page ):
1855
1855
""" This method opens the start_page, creates a referral link there,
@@ -2348,16 +2348,16 @@ def __add_delayed_assert_failure(self):
2348
2348
""" Add a delayed_assert failure into a list for future processing. """
2349
2349
current_url = self .driver .current_url
2350
2350
message = self .__get_exception_message ()
2351
- self ._page_check_failures .append (
2351
+ self .__page_check_failures .append (
2352
2352
"CHECK #%s: (%s)\n %s" % (
2353
- self ._page_check_count , current_url , message ))
2353
+ self .__page_check_count , current_url , message ))
2354
2354
2355
2355
def delayed_assert_element (self , selector , by = By .CSS_SELECTOR ,
2356
2356
timeout = settings .MINI_TIMEOUT ):
2357
2357
""" A non-terminating assertion for an element on a page.
2358
2358
Failures will be saved until the process_delayed_asserts()
2359
2359
method is called from inside a test, likely at the end of it. """
2360
- self ._page_check_count += 1
2360
+ self .__page_check_count += 1
2361
2361
try :
2362
2362
url = self .get_current_url ()
2363
2363
if url == self .__last_url_of_delayed_assert :
@@ -2384,7 +2384,7 @@ def delayed_assert_text(self, text, selector, by=By.CSS_SELECTOR,
2384
2384
""" A non-terminating assertion for text from an element on a page.
2385
2385
Failures will be saved until the process_delayed_asserts()
2386
2386
method is called from inside a test, likely at the end of it. """
2387
- self ._page_check_count += 1
2387
+ self .__page_check_count += 1
2388
2388
try :
2389
2389
url = self .get_current_url ()
2390
2390
if url == self .__last_url_of_delayed_assert :
@@ -2417,12 +2417,12 @@ def process_delayed_asserts(self, print_only=False):
2417
2417
the delayed asserts on a single html page so that the failure
2418
2418
screenshot matches the location of the delayed asserts.
2419
2419
If "print_only" is set to True, the exception won't get raised. """
2420
- if self ._page_check_failures :
2420
+ if self .__page_check_failures :
2421
2421
exception_output = ''
2422
2422
exception_output += "\n *** DELAYED ASSERTION FAILURES FOR: "
2423
2423
exception_output += "%s\n " % self .id ()
2424
- all_failing_checks = self ._page_check_failures
2425
- self ._page_check_failures = []
2424
+ all_failing_checks = self .__page_check_failures
2425
+ self .__page_check_failures = []
2426
2426
for tb in all_failing_checks :
2427
2427
exception_output += "%s\n " % tb
2428
2428
if print_only :
@@ -2495,8 +2495,8 @@ def __click_dropdown_link_text(self, link_text, link_css):
2495
2495
return False
2496
2496
2497
2497
def __pick_select_option (self , dropdown_selector , option ,
2498
- dropdown_by = By .CSS_SELECTOR , option_by = "text" ,
2499
- timeout = settings .SMALL_TIMEOUT ):
2498
+ dropdown_by = By .CSS_SELECTOR , option_by = "text" ,
2499
+ timeout = settings .SMALL_TIMEOUT ):
2500
2500
""" Picks an HTML <select> option by specification.
2501
2501
Option specifications are by "text", "index", or "value".
2502
2502
Defaults to "text" if option_by is unspecified or unknown. """
@@ -2888,7 +2888,7 @@ def tearDown(self):
2888
2888
has_exception = True
2889
2889
else :
2890
2890
has_exception = sys .exc_info ()[1 ] is not None
2891
- if self ._page_check_failures :
2891
+ if self .__page_check_failures :
2892
2892
print (
2893
2893
"\n When using self.delayed_assert_*() methods in your tests, "
2894
2894
"remember to call self.process_delayed_asserts() afterwards. "
0 commit comments