Skip to content

Commit 8fd8c1a

Browse files
committed
Refactoring tour styles
1 parent 2f529d8 commit 8fd8c1a

File tree

2 files changed

+50
-48
lines changed

2 files changed

+50
-48
lines changed

seleniumbase/core/style_sheet.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,47 @@
9696
padding-left: 20px;
9797
}
9898
</style>'''
99+
100+
sh_style_test = (
101+
'''
102+
let test_tour = new Shepherd.Tour({
103+
defaults: {
104+
classes: 'shepherd-theme-dark',
105+
scrollTo: true
106+
}
107+
});
108+
''')
109+
110+
sh_backdrop_style = (
111+
'''
112+
body.shepherd-active .shepherd-target.shepherd-enabled {
113+
box-shadow: 0 0 0 99999px rgba(0, 0, 0, 0.22);
114+
pointer-events: none !important;
115+
z-index: 9999;
116+
}
117+
118+
body.shepherd-active .shepherd-orphan {
119+
box-shadow: 0 0 0 99999px rgba(0, 0, 0, 0.16);
120+
pointer-events: auto;
121+
z-index: 9999;
122+
}
123+
124+
body.shepherd-active
125+
.shepherd-enabled.shepherd-element-attached-top {
126+
position: relative;
127+
}
128+
129+
body.shepherd-active
130+
.shepherd-enabled.shepherd-element-attached-bottom {
131+
position: relative;
132+
}
133+
134+
body.shepherd-active .shepherd-step {
135+
pointer-events: auto;
136+
z-index: 9999;
137+
}
138+
139+
body.shepherd-active {
140+
pointer-events: none !important;
141+
}
142+
''')

seleniumbase/fixtures/base_case.py

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def test_anything(self):
4242
from seleniumbase.core.testcase_manager import TestcaseManager
4343
from seleniumbase.core import download_helper
4444
from seleniumbase.core import log_helper
45+
from seleniumbase.core import style_sheet
4546
from seleniumbase.fixtures import constants
4647
from seleniumbase.fixtures import page_actions
4748
from seleniumbase.fixtures import page_utils
@@ -860,46 +861,8 @@ def __activate_shepherd(self):
860861
backbone_js = constants.Backbone.MIN_JS
861862
spinner_css = constants.Messenger.SPINNER_CSS
862863

863-
backdrop_style = (
864-
'''
865-
body.shepherd-active .shepherd-target.shepherd-enabled {
866-
box-shadow: 0 0 0 99999px rgba(0, 0, 0, 0.22);
867-
pointer-events: none !important;
868-
z-index: 9999;
869-
}
870-
871-
body.shepherd-active .shepherd-orphan {
872-
box-shadow: 0 0 0 99999px rgba(0, 0, 0, 0.16);
873-
pointer-events: auto;
874-
z-index: 9999;
875-
}
876-
877-
body.shepherd-active
878-
.shepherd-enabled.shepherd-element-attached-top {
879-
position: relative;
880-
}
881-
882-
body.shepherd-active
883-
.shepherd-enabled.shepherd-element-attached-bottom {
884-
position: relative;
885-
}
886-
887-
body.shepherd-active .shepherd-step {
888-
pointer-events: auto;
889-
z-index: 9999;
890-
}
891-
892-
body.shepherd-active {
893-
pointer-events: none !important;
894-
}
895-
''')
896-
897-
sh_style = ("""let test_tour = new Shepherd.Tour({
898-
defaults: {
899-
classes: 'shepherd-theme-dark',
900-
scrollTo: true
901-
}
902-
});""")
864+
sh_style = style_sheet.sh_style_test
865+
backdrop_style = style_sheet.sh_backdrop_style
903866

904867
self.__activate_bootstrap()
905868
for x in range(4):
@@ -922,7 +885,7 @@ def __activate_shepherd(self):
922885
for x in range(int(settings.MINI_TIMEOUT * 2.0)):
923886
# Shepherd needs a small amount of time to load & activate.
924887
try:
925-
self.execute_script(sh_style)
888+
self.execute_script(sh_style) # Verify Shepherd has loaded
926889
self.wait_for_ready_state_complete()
927890
self.execute_script(sh_style) # Need it twice for ordering
928891
time.sleep(0.05)
@@ -936,14 +899,9 @@ def __activate_shepherd(self):
936899
'''directive. ''' % self.driver.current_url)
937900

938901
def __is_shepherd_activated(self):
939-
sh_style = ("""let test_tour = new Shepherd.Tour({
940-
defaults: {
941-
classes: 'shepherd-theme-dark',
942-
scrollTo: true
943-
}
944-
});""")
902+
sh_style = style_sheet.sh_style_test
945903
try:
946-
self.execute_script(sh_style)
904+
self.execute_script(sh_style) # Verify Shepherd has loaded
947905
return True
948906
except Exception:
949907
return False

0 commit comments

Comments
 (0)