Skip to content

Commit d411c4b

Browse files
committed
Update console scripts
1 parent c5c8c0b commit d411c4b

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

console_scripts/run.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Examples:
88
seleniumbase mkdir [DIRECTORY_NAME]
9-
seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE].py
9+
seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE]
1010
seleniumbase grid-hub start
1111
seleniumbase grid-node start --hub=127.0.0.1
1212
"""
@@ -20,7 +20,8 @@
2020

2121
def show_usage():
2222
show_basic_usage()
23-
print('Type "seleniumbase help" for more details.\n')
23+
print('Type "seleniumbase help" for details on all commands. OR,')
24+
print('Type "seleniumbase help [COMMAND]" for specific command info.\n')
2425

2526

2627
def show_basic_usage():
@@ -31,8 +32,8 @@ def show_basic_usage():
3132
print("")
3233
print("Commands:")
3334
print("")
34-
print(" mkdir [DIRECTORY]")
35-
print(" convert [FILENAME]")
35+
print(" mkdir [NEW_TEST_DIRECTORY_NAME]")
36+
print(" convert [PYTHON_WEBDRIVER_UNITTEST_FILE]")
3637
print(" grid-hub {start|stop|restart} [OPTIONS]")
3738
print(" grid-node {start|stop|restart} --hub=[HUB_IP] [OPTIONS]")
3839
print("")
@@ -56,7 +57,7 @@ def show_convert_usage():
5657
print(" ** convert **")
5758
print("")
5859
print(" Usage:")
59-
print(" seleniumbase convert [MY_TEST.py]")
60+
print(" seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE]")
6061
print(" Output:")
6162
print(" Converts a Selenium IDE exported WebDriver unittest")
6263
print(" file into a SeleniumBase file. Adds _SB to the new")
@@ -147,6 +148,23 @@ def main():
147148
show_basic_usage()
148149
show_grid_node_usage()
149150
elif command == "help" or command == "--help":
151+
if len(command_args) >= 1:
152+
if command_args[0] == "mkdir":
153+
print("")
154+
show_mkdir_usage()
155+
return
156+
elif command_args[0] == "convert":
157+
print("")
158+
show_convert_usage()
159+
return
160+
elif command_args[0] == "grid-hub":
161+
print("")
162+
show_grid_hub_usage()
163+
return
164+
elif command_args[0] == "grid-node":
165+
print("")
166+
show_grid_node_usage()
167+
return
150168
show_detailed_help()
151169
else:
152170
show_usage()

integrations/selenium_ide/convert_ide.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
Works with Katalon Recorder scripts: http://www.katalon.com/automation-recorder
55
66
Usage:
7-
seleniumbase convert [MY_TEST.py]
7+
seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE].py
8+
(run from anywhere)
89
OR
9-
python convert_ide.py [MY_TEST.py] (from the "selenium_ide/"" folder)
10+
python convert_ide.py [PYTHON_WEBDRIVER_UNITTEST_FILE].py
11+
(when run from the "selenium_ide/" folder)
1012
Output:
11-
[MY_TEST_SB.py] (Adds "_SB" to the file name)
13+
[NEW_FILE_SB].py (adds "_SB" to the original file name)
14+
(the original file is kept intact)
1215
"""
1316

1417
import codecs
@@ -18,7 +21,7 @@
1821

1922
def main():
2023
expected_arg = ("[A Katalon/Selenium IDE recording exported as "
21-
"a Python-WebDriver script].py")
24+
"a Python-WebDriver unittest script].py")
2225
num_args = len(sys.argv)
2326
if sys.argv[0].split('/')[-1] == "seleniumbase" or (
2427
sys.argv[0].split('\\')[-1] == "seleniumbase"):
@@ -29,9 +32,11 @@ def main():
2932
if num_args < 2 or num_args > 2:
3033
raise Exception('\n* INVALID RUN COMMAND! * Usage:\n'
3134
'"python convert_ide.py %s"\n' % expected_arg)
32-
if not sys.argv[num_args-1].endswith('.py'):
33-
raise Exception("Not a Python file!")
3435
webdriver_python_file = sys.argv[num_args-1]
36+
if not webdriver_python_file.endswith('.py'):
37+
raise Exception("* `%s` is not a Python file! *\n"
38+
"Expecting: %s\n"
39+
% (webdriver_python_file, expected_arg))
3540

3641
seleniumbase_lines = []
3742
seleniumbase_lines.append("from seleniumbase import BaseCase")
@@ -47,7 +52,10 @@ def main():
4752
all_code = f.read()
4853
f.close()
4954
if "def test_" not in all_code:
50-
raise Exception("Not a valid Python unittest.TestCase file!")
55+
raise Exception("* `%s` is not a valid Python unittest.TestCase file! "
56+
"*\nExpecting: %s\n"
57+
"Did you properly export your Selenium-IDE recording "
58+
"as a Python WebDriver unittest file?" % expected_arg)
5159
code_lines = all_code.split('\n')
5260
for line in code_lines:
5361

0 commit comments

Comments
 (0)