Skip to content

Commit 2175de7

Browse files
committed
Update console scripts
1 parent bd55130 commit 2175de7

File tree

3 files changed

+47
-17
lines changed

3 files changed

+47
-17
lines changed

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -453,23 +453,33 @@ def main():
453453
data.append("BaseCase.main(__name__, __file__)")
454454
data.append("")
455455
data.append("")
456-
data.append("class GoogleTests(BaseCase):")
456+
data.append("class SearchTests(BaseCase):")
457457
data.append(" @parameterized.expand(")
458458
data.append(" [")
459-
data.append(' ["Download Python", "Download Python"],')
460-
data.append(' ["wikipedia", "www.wikipedia.org"],')
461-
data.append(' ["SeleniumBase.io Docs", "SeleniumBase"],')
459+
data.append(
460+
" "
461+
'["SeleniumBase Commander", "Commander", "GUI / Commander"],'
462+
)
463+
data.append(
464+
' ["SeleniumBase Recorder", "Recorder", "Recorder Mode"],'
465+
)
466+
data.append(
467+
' ["SeleniumBase Syntax", "Syntax", "Syntax Formats"],'
468+
)
462469
data.append(" ]")
463470
data.append(" )")
464471
data.append(
465-
" def test_parameterized_google_search("
466-
"self, search_term, expected_text):"
472+
" def test_parameterized_search("
473+
"self, search_term, keyword, title_text):"
474+
)
475+
data.append(
476+
' self.open("https://seleniumbase.io/help_docs/how_it_works/")'
467477
)
468-
data.append(' self.open("https://google.com/ncr")')
469478
data.append(
470-
' self.type(\'input[title="Search"]\', search_term + "\\n")'
479+
' self.type(\'input[aria-label="Search"]\', search_term)'
471480
)
472-
data.append(' self.assert_text(expected_text, "#search")')
481+
data.append(' self.click(\'mark:contains("%s")\' % keyword)')
482+
data.append(' self.assert_title_contains(title_text)')
473483
data.append("")
474484
file_path = "%s/%s" % (dir_name, "parameterized_test.py")
475485
file = codecs.open(file_path, "w+", "utf-8")

seleniumbase/console_scripts/sb_mkrec.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
import os
3636
import sys
3737

38+
PLATFORM = sys.platform
39+
IS_WINDOWS = False
40+
if "win32" in PLATFORM or "win64" in PLATFORM or "x64" in PLATFORM:
41+
IS_WINDOWS = True
42+
3843

3944
def invalid_run_command(msg=None):
4045
exp = " ** mkrec / record / codegen **\n\n"
@@ -195,19 +200,24 @@ def main():
195200
run_cmd += " --uc"
196201
if rec_behave:
197202
run_cmd += " --rec-behave"
203+
if IS_WINDOWS:
204+
run_cmd = "python.exe -m %s" % run_cmd
198205
print(run_cmd)
199206
os.system(run_cmd)
200207
if os.path.exists(file_path):
201208
os.remove(file_path)
202209
recorded_filename = file_name[:-3] + "_rec.py"
203210
recordings_dir = os.path.join(dir_name, "recordings")
204211
recorded_file = os.path.join(recordings_dir, recorded_filename)
212+
prefix = ""
213+
if IS_WINDOWS:
214+
prefix = "python.exe -m "
205215
if " " not in recorded_file:
206-
os.system("sbase print %s -n" % recorded_file)
216+
os.system("%sseleniumbase print %s -n" % (prefix, recorded_file))
207217
elif '"' not in recorded_file:
208-
os.system('sbase print "%s" -n' % recorded_file)
218+
os.system('%sseleniumbase print "%s" -n' % (prefix, recorded_file))
209219
else:
210-
os.system("sbase print '%s' -n" % recorded_file)
220+
os.system("%sseleniumbase print '%s' -n" % (prefix, recorded_file))
211221
shutil.copy(recorded_file, file_path)
212222
success = (
213223
"\n" + c2 + "***" + cr + " RECORDING COPIED to: "
@@ -220,11 +230,11 @@ def main():
220230
features_dir = os.path.join(recordings_dir, "features")
221231
recorded_file = os.path.join(features_dir, recorded_filename)
222232
if " " not in recorded_file:
223-
os.system("sbase print %s -n" % recorded_file)
233+
os.system("%sseleniumbase print %s -n" % (prefix, recorded_file))
224234
elif '"' not in recorded_file:
225-
os.system('sbase print "%s" -n' % recorded_file)
235+
os.system('%sseleniumbase print "%s" -n' % (prefix, recorded_file))
226236
else:
227-
os.system("sbase print '%s' -n" % recorded_file)
237+
os.system("%sseleniumbase print '%s' -n" % (prefix, recorded_file))
228238
success = (
229239
"\n" + c2 + "***" + cr + " BEHAVE RECORDING at: "
230240
"" + c1 + os.path.relpath(recorded_file) + cr + "\n"

seleniumbase/console_scripts/sb_recorder.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""
2+
** recorder **
3+
24
Launches the SeleniumBase Recorder Desktop App.
35
46
Usage:
@@ -19,6 +21,10 @@
1921
from seleniumbase import config as sb_config
2022
from seleniumbase.fixtures import page_utils
2123

24+
PLATFORM = sys.platform
25+
IS_WINDOWS = False
26+
if "win32" in PLATFORM or "win64" in PLATFORM or "x64" in PLATFORM:
27+
IS_WINDOWS = True
2228
sb_config.rec_subprocess_p = None
2329
sb_config.rec_subprocess_used = False
2430
if sys.version_info <= (3, 7):
@@ -128,7 +134,9 @@ def do_recording(file_name, url, overwrite_enabled, use_chrome, window):
128134
or "--gherkin" in command_args
129135
):
130136
add_on = " --rec-behave"
131-
command = "sbase mkrec %s --url=%s --gui" % (file_name, url)
137+
command = "seleniumbase mkrec %s --url=%s --gui" % (file_name, url)
138+
if IS_WINDOWS:
139+
command = "python.exe -m %s" % command
132140
if not use_chrome:
133141
command += " --edge"
134142
if (
@@ -164,6 +172,8 @@ def do_playback(file_name, use_chrome, window, demo_mode=False):
164172
)
165173
return
166174
command = "pytest %s -q -s" % file_name
175+
if IS_WINDOWS:
176+
command = "python.exe -m %s" % command
167177
if "linux" in sys.platform:
168178
command += " --gui"
169179
if not use_chrome:
@@ -320,4 +330,4 @@ def main():
320330

321331

322332
if __name__ == "__main__":
323-
print('To open the Recorder Desktop App: "sbase recorder"')
333+
print('To open the Recorder Desktop App: "seleniumbase recorder"')

0 commit comments

Comments
 (0)