Refresh Recorder Mode with "codegen" and more
This commit is contained in:
parent
2a46f6f6a9
commit
f6737bc13f
|
@ -11,7 +11,7 @@ sbase methods
|
|||
sbase options
|
||||
sbase mkdir ui_tests
|
||||
sbase mkfile new_test.py
|
||||
sbase mkrec new_test.py
|
||||
sbase mkrec new_test.py # Same as "sbase codegen new_test.py"
|
||||
sbase mkpres new_presentation.py
|
||||
sbase mkchart new_chart.py
|
||||
sbase convert webdriver_unittest_file.py
|
||||
|
@ -70,26 +70,26 @@ def show_basic_usage():
|
|||
sc += ' * OR: "sbase [COMMAND] [PARAMETERS]"\n'
|
||||
sc += "\n"
|
||||
sc += "COMMANDS:\n"
|
||||
sc += " install [DRIVER] [OPTIONS]\n"
|
||||
sc += " methods (List common Python methods)\n"
|
||||
sc += " options (List common pytest options)\n"
|
||||
sc += " mkdir [DIRECTORY] [OPTIONS]\n"
|
||||
sc += " mkfile [FILE.py] [OPTIONS]\n"
|
||||
sc += " mkrec [FILE.py]\n"
|
||||
sc += " mkpres [FILE.py] [LANG]\n"
|
||||
sc += " mkchart [FILE.py] [LANG]\n"
|
||||
sc += " print [FILE] [OPTIONS]\n"
|
||||
sc += " translate [SB_FILE.py] [LANG] [ACTION]\n"
|
||||
sc += " convert [WEBDRIVER_UNITTEST_FILE.py]\n"
|
||||
sc += " extract-objects [SB_FILE.py]\n"
|
||||
sc += " inject-objects [SB_FILE.py] [OPTIONS]\n"
|
||||
sc += " objectify [SB_FILE.py] [OPTIONS]\n"
|
||||
sc += " revert-objects [SB_FILE.py] [OPTIONS]\n"
|
||||
sc += " encrypt (OR: obfuscate)\n"
|
||||
sc += " decrypt (OR: unobfuscate)\n"
|
||||
sc += " download server (The Selenium Grid JAR file)\n"
|
||||
sc += " grid-hub [start|stop] [OPTIONS]\n"
|
||||
sc += " grid-node [start|stop] --hub=[HOST/IP]\n"
|
||||
sc += " install [DRIVER] [OPTIONS]\n"
|
||||
sc += " methods (List common Python methods)\n"
|
||||
sc += " options (List common pytest options)\n"
|
||||
sc += " mkdir [DIRECTORY] [OPTIONS]\n"
|
||||
sc += " mkfile [FILE.py] [OPTIONS]\n"
|
||||
sc += " mkrec / codegen [FILE.py]\n"
|
||||
sc += " mkpres [FILE.py] [LANG]\n"
|
||||
sc += " mkchart [FILE.py] [LANG]\n"
|
||||
sc += " print [FILE] [OPTIONS]\n"
|
||||
sc += " translate [SB_FILE.py] [LANG] [ACTION]\n"
|
||||
sc += " convert [WEBDRIVER_UNITTEST_FILE.py]\n"
|
||||
sc += " extract-objects [SB_FILE.py]\n"
|
||||
sc += " inject-objects [SB_FILE.py] [OPTIONS]\n"
|
||||
sc += " objectify [SB_FILE.py] [OPTIONS]\n"
|
||||
sc += " revert-objects [SB_FILE.py] [OPTIONS]\n"
|
||||
sc += " encrypt / obfuscate\n"
|
||||
sc += " decrypt / unobfuscate\n"
|
||||
sc += " download server (Get Selenium Grid JAR file)\n"
|
||||
sc += " grid-hub [start|stop] [OPTIONS]\n"
|
||||
sc += " grid-node [start|stop] --hub=[HOST/IP]\n"
|
||||
sc += ' * (EXAMPLE: "sbase install chromedriver latest") *\n'
|
||||
sc += ""
|
||||
if "linux" not in sys.platform:
|
||||
|
@ -176,7 +176,7 @@ def show_mkfile_usage():
|
|||
print(" sbase mkfile new_test.py")
|
||||
print(" Options:")
|
||||
print(" -b / --basic (Basic boilerplate / single-line test)")
|
||||
print(" -r / --recorder (Recorder Mode has ipdb breakpoint)")
|
||||
print(" -r / --rec (adds ipdb breakpoint for Recorder Mode)")
|
||||
print(" Language Options:")
|
||||
print(" --en / --English | --zh / --Chinese")
|
||||
print(" --nl / --Dutch | --fr / --French")
|
||||
|
@ -213,6 +213,24 @@ def show_mkrec_usage():
|
|||
print("")
|
||||
|
||||
|
||||
def show_codegen_usage():
|
||||
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
|
||||
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
|
||||
cr = colorama.Style.RESET_ALL
|
||||
sc = " " + c2 + "** " + c3 + "codegen" + c2 + " **" + cr
|
||||
print(sc)
|
||||
print("")
|
||||
print(" Usage:")
|
||||
print(" seleniumbase codegen [FILE.py]")
|
||||
print(" OR: sbase codegen [FILE.py]")
|
||||
print(" Example:")
|
||||
print(" sbase codegen new_test.py")
|
||||
print(" Output:")
|
||||
print(" Creates a new SeleniumBase test using the Recorder.")
|
||||
print(" If the filename already exists, an error is raised.")
|
||||
print("")
|
||||
|
||||
|
||||
def show_mkpres_usage():
|
||||
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
|
||||
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
|
||||
|
@ -701,6 +719,7 @@ def show_detailed_help():
|
|||
show_mkdir_usage()
|
||||
show_mkfile_usage()
|
||||
show_mkrec_usage()
|
||||
show_codegen_usage()
|
||||
show_mkpres_usage()
|
||||
show_mkchart_usage()
|
||||
show_convert_usage()
|
||||
|
@ -765,6 +784,14 @@ def main():
|
|||
else:
|
||||
show_basic_usage()
|
||||
show_mkrec_usage()
|
||||
elif command == "codegen":
|
||||
if len(command_args) >= 1:
|
||||
from seleniumbase.console_scripts import sb_mkrec
|
||||
|
||||
sb_mkrec.main()
|
||||
else:
|
||||
show_basic_usage()
|
||||
show_codegen_usage()
|
||||
elif command == "mkpres":
|
||||
if len(command_args) >= 1:
|
||||
from seleniumbase.console_scripts import sb_mkpres
|
||||
|
@ -920,6 +947,10 @@ def main():
|
|||
print("")
|
||||
show_mkrec_usage()
|
||||
return
|
||||
elif command_args[0] == "codegen":
|
||||
print("")
|
||||
show_codegen_usage()
|
||||
return
|
||||
elif command_args[0] == "mkpres":
|
||||
print("")
|
||||
show_mkpres_usage()
|
||||
|
|
|
@ -11,7 +11,7 @@ Example:
|
|||
|
||||
Options:
|
||||
-b / --basic (Basic boilerplate / single-line test)
|
||||
-r / --recorder (Recorder Mode has ipdb breakpoint)
|
||||
-r / --rec (adds ipdb breakpoint for Recorder Mode)
|
||||
|
||||
Language Options:
|
||||
--en / --English | --zh / --Chinese
|
||||
|
@ -46,7 +46,7 @@ def invalid_run_command(msg=None):
|
|||
exp += " sbase mkfile new_test.py\n"
|
||||
exp += " Options:\n"
|
||||
exp += " -b / --basic (Basic boilerplate / single-line test)\n"
|
||||
exp += " -r / --recorder (Recorder Mode has ipdb breakpoint)\n"
|
||||
exp += " -r / --rec (adds ipdb breakpoint for Recorder Mode)\n"
|
||||
exp += " Language Options:\n"
|
||||
exp += " --en / --English | --zh / --Chinese\n"
|
||||
exp += " --nl / --Dutch | --fr / --French\n"
|
||||
|
|
|
@ -3,11 +3,14 @@
|
|||
Creates a new SeleniumBase test file using the Recorder.
|
||||
|
||||
Usage:
|
||||
seleniumbase mkrec [FILE.py]
|
||||
or sbase mkrec [FILE.py]
|
||||
seleniumbase mkrec [FILE.py]
|
||||
sbase mkrec [FILE.py]
|
||||
seleniumbase codegen [FILE.py]
|
||||
sbase codegen [FILE.py]
|
||||
|
||||
Example:
|
||||
Examples:
|
||||
sbase mkrec new_test.py
|
||||
sbase codegen new_test.py
|
||||
|
||||
Output:
|
||||
Creates a new SeleniumBase test using the Recorder.
|
||||
|
@ -22,12 +25,15 @@ import sys
|
|||
|
||||
|
||||
def invalid_run_command(msg=None):
|
||||
exp = " ** mkrec **\n\n"
|
||||
exp = " ** mkrec / codegen **\n\n"
|
||||
exp += " Usage:\n"
|
||||
exp += " seleniumbase mkrec [FILE.py]\n"
|
||||
exp += " OR sbase mkrec [FILE.py]\n"
|
||||
exp += " Example:\n"
|
||||
exp += " sbase mkrec [FILE.py]\n"
|
||||
exp += " seleniumbase codegen [FILE.py]\n"
|
||||
exp += " sbase codegen [FILE.py]\n"
|
||||
exp += " Examples:\n"
|
||||
exp += " sbase mkrec new_test.py\n"
|
||||
exp += " sbase codegen new_test.py\n"
|
||||
exp += " Output:\n"
|
||||
exp += " Creates a new SeleniumBase test using the Recorder.\n"
|
||||
exp += " If the filename already exists, an error is raised.\n"
|
||||
|
|
Binary file not shown.
|
@ -606,7 +606,7 @@ document.body.addEventListener('mouseup', function (event) {
|
|||
else if (ra_len > 0 &&
|
||||
document.recorded_actions[ra_len-1][0] === 'mo_dn')
|
||||
{
|
||||
// Probably an accidental drag & drop.
|
||||
// Maybe an accidental drag & drop.
|
||||
document.recorded_actions.pop();
|
||||
}
|
||||
json_rec_act = JSON.stringify(document.recorded_actions);
|
||||
|
@ -642,14 +642,15 @@ document.body.addEventListener('keydown', function (event) {
|
|||
});
|
||||
document.body.addEventListener('keyup', function (event) {
|
||||
reset_if_recorder_undefined();
|
||||
// Controls for Pausing & Resuming.
|
||||
// Controls to Pause & Resume.
|
||||
pause_rec = sessionStorage.getItem('pause_recorder');
|
||||
if (event.key.toLowerCase() === 'escape' && pause_rec === 'no')
|
||||
rec_mode = sessionStorage.getItem('recorder_mode');
|
||||
l_key = event.key.toLowerCase();
|
||||
if (l_key === 'escape' && pause_rec === 'no' && rec_mode === '1')
|
||||
{
|
||||
sessionStorage.setItem('pause_recorder', 'yes');
|
||||
pause_rec = 'yes';
|
||||
sessionStorage.setItem('recorder_mode', '1');
|
||||
console.log('The SeleniumBase Recorder has paused.');
|
||||
console.log('SeleniumBase Recorder paused');
|
||||
no_border = 'none';
|
||||
document.querySelector('body').style.border = no_border;
|
||||
document.title = sessionStorage.getItem('recorder_title');
|
||||
|
@ -658,15 +659,14 @@ document.body.addEventListener('keyup', function (event) {
|
|||
{
|
||||
sessionStorage.setItem('pause_recorder', 'no');
|
||||
pause_rec = 'no';
|
||||
sessionStorage.setItem('recorder_mode', '1');
|
||||
console.log('The SeleniumBase Recorder has resumed.');
|
||||
console.log('SeleniumBase Recorder resumed');
|
||||
red_border = 'thick solid #EE3344';
|
||||
document.querySelector('body').style.border = red_border;
|
||||
}
|
||||
else if (event.key === '^' && pause_rec === 'no')
|
||||
{
|
||||
sessionStorage.setItem('recorder_mode', '2');
|
||||
purple_border = 'thick solid #BF40BF';
|
||||
purple_border = 'thick solid #EF5BE9';
|
||||
document.querySelector('body').style.border = purple_border;
|
||||
}
|
||||
else if (event.key === '&' && pause_rec === 'no')
|
||||
|
@ -675,13 +675,13 @@ document.body.addEventListener('keyup', function (event) {
|
|||
orange_border = 'thick solid #F28C28';
|
||||
document.querySelector('body').style.border = orange_border;
|
||||
}
|
||||
else if (pause_rec === 'no' && event.key.toLowerCase() !== 'shift')
|
||||
else if (pause_rec === 'no' && l_key !== 'shift' && l_key !== 'backspace')
|
||||
{
|
||||
sessionStorage.setItem('recorder_mode', '1');
|
||||
red_border = 'thick solid #EE3344';
|
||||
document.querySelector('body').style.border = red_border;
|
||||
}
|
||||
// After checking for pause/resume controls.
|
||||
// After controls for switching modes.
|
||||
if (sessionStorage.getItem('pause_recorder') === 'yes') return;
|
||||
const d_now = Date.now();
|
||||
const element = event.target;
|
||||
|
@ -692,7 +692,7 @@ document.body.addEventListener('keyup', function (event) {
|
|||
element.tagName.toLowerCase() === 'textarea')
|
||||
{
|
||||
ra_len = document.recorded_actions.length;
|
||||
if (ra_len > 0 && event.key.toLowerCase() === 'enter' &&
|
||||
if (ra_len > 0 && l_key === 'enter' &&
|
||||
document.recorded_actions[ra_len-1][0] === 'input' &&
|
||||
document.recorded_actions[ra_len-1][1] === selector &&
|
||||
!document.recorded_actions[ra_len-1][2].endsWith('\n'))
|
||||
|
|
|
@ -660,6 +660,7 @@ def pytest_addoption(parser):
|
|||
"--recorder",
|
||||
"--record",
|
||||
"--rec",
|
||||
"--codegen",
|
||||
action="store_true",
|
||||
dest="recorder_mode",
|
||||
default=False,
|
||||
|
|
|
@ -421,6 +421,7 @@ class SeleniumBrowser(Plugin):
|
|||
"--recorder",
|
||||
"--record",
|
||||
"--rec",
|
||||
"--codegen",
|
||||
action="store_true",
|
||||
dest="recorder_mode",
|
||||
default=False,
|
||||
|
|
Loading…
Reference in New Issue