44Works with Katalon Recorder scripts: http://www.katalon.com/automation-recorder
55
66Usage:
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)
1012Output:
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
1417import codecs
1821
1922def 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+ "*\n Expecting: %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