|
1 | 1 | """
|
2 |
| -Converts a Selenium IDE WebDriver-exported test file into a SeleniumBase file. |
| 2 | +Converts a Selenium IDE recording that was exported as a Python WebDriver |
| 3 | +unittest file into SeleniumBase Python file. |
3 | 4 | Works with Katalon Recorder scripts: http://www.katalon.com/automation-recorder
|
4 | 5 |
|
5 | 6 | Usage:
|
6 |
| -python convert_ide.py [MY_TEST.py] |
| 7 | + seleniumbase convert [MY_TEST.py] |
| 8 | + OR |
| 9 | + python convert_ide.py [MY_TEST.py] (from the "selenium_ide/"" folder) |
7 | 10 | Output:
|
8 |
| -[MY_TEST_SB.py] (Adds "_SB" to the file name) |
| 11 | + [MY_TEST_SB.py] (Adds "_SB" to the file name) |
9 | 12 | """
|
10 | 13 |
|
11 | 14 | import codecs
|
|
14 | 17 |
|
15 | 18 |
|
16 | 19 | def main():
|
17 |
| - expected_arg = "[A Selenium IDE recording exported to Python WebDriver]" |
| 20 | + expected_arg = ("[A Katalon/Selenium IDE recording exported as " |
| 21 | + "a Python-WebDriver script].py") |
18 | 22 | num_args = len(sys.argv)
|
19 |
| - if num_args < 2 or num_args > 2: |
20 |
| - raise Exception("\n* INVALID RUN COMMAND! * Usage:\n" |
21 |
| - "python convert_ide.py %s\n" % expected_arg) |
22 |
| - elif num_args == 2: |
23 |
| - if not sys.argv[1].endswith('.py'): |
24 |
| - raise Exception("Not a Python file!") |
25 |
| - webdriver_python_file = sys.argv[1] |
| 23 | + if sys.argv[0].split('/')[-1] == "seleniumbase" or ( |
| 24 | + sys.argv[0].split('\\')[-1] == "seleniumbase"): |
| 25 | + if num_args < 3 or num_args > 3: |
| 26 | + raise Exception('\n* INVALID RUN COMMAND! * Usage:\n' |
| 27 | + '"seleniumbase convert %s"\n' % expected_arg) |
| 28 | + else: |
| 29 | + if num_args < 2 or num_args > 2: |
| 30 | + raise Exception('\n* INVALID RUN COMMAND! * Usage:\n' |
| 31 | + '"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!") |
| 34 | + webdriver_python_file = sys.argv[num_args-1] |
26 | 35 |
|
27 | 36 | seleniumbase_lines = []
|
28 | 37 | seleniumbase_lines.append("from seleniumbase import BaseCase")
|
|
0 commit comments