Skip to content

Commit 10446ad

Browse files
committed
Prepare Selenium IDE converter tool as a console script
1 parent ed5972e commit 10446ad

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

integrations/selenium_ide/ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Converting Katalon-based Selenium IDE recordings into SeleniumBase test scripts
1+
## Converting Katalon/Selenium IDE recordings into SeleniumBase test scripts
22

33
[Katelon Recorder / Selenium IDE](https://www.katalon.com/resources-center/blog/katalon-automation-recorder/) (<i>the successor to the [old Selenium IDE](http://docs.seleniumhq.org/projects/ide/)</i>) is a tool that allows you to record and playback actions performed inside a web browser. It's available as a [downloadable Chrome extension](https://chrome.google.com/webstore/detail/katalon-recorder-selenium/ljdobmomdgdljniojadhoplhkpialdid) and a [downloadable Firefox extension](https://addons.mozilla.org/en-US/firefox/addon/katalon-automation-record/). Katelon Recorder comes with an option to export recordings as various WebDriver test scripts, one of which is ``Python 2 (WebDriver + unittest)``. Unfortunately, these natively-exported scripts can be very messy and don't always run reliably. The purpose of this converter is to clean up and improve the scripts so that they can be used in production-level environments.
44

integrations/selenium_ide/__init__.py

Whitespace-only changes.

integrations/selenium_ide/convert_ide.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
"""
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.
34
Works with Katalon Recorder scripts: http://www.katalon.com/automation-recorder
45
56
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)
710
Output:
8-
[MY_TEST_SB.py] (Adds "_SB" to the file name)
11+
[MY_TEST_SB.py] (Adds "_SB" to the file name)
912
"""
1013

1114
import codecs
@@ -14,15 +17,21 @@
1417

1518

1619
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")
1822
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]
2635

2736
seleniumbase_lines = []
2837
seleniumbase_lines.append("from seleniumbase import BaseCase")

0 commit comments

Comments
 (0)