Skip to content

Commit 1754cfc

Browse files
committed
Update console scripts
1 parent 67068c8 commit 1754cfc

File tree

3 files changed

+63
-11
lines changed

3 files changed

+63
-11
lines changed

seleniumbase/console_scripts/run.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,7 @@ def show_convert_usage():
417417
print(" Converts a Selenium IDE exported WebDriver unittest")
418418
print(" file into a SeleniumBase file. Adds _SB to the new")
419419
print(" file name while keeping the original file intact.")
420-
print(" Works with Katalon Recorder scripts.")
421-
print(" See: http://www.katalon.com/automation-recorder")
420+
print(" (Works with Katalon Recorder Selenium scripts.)")
422421
print("")
423422

424423

seleniumbase/console_scripts/sb_objectify.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,61 @@ def process_test_file(
22752275
seleniumbase_lines.append(command)
22762276
continue
22772277

2278+
# Handle self.wait_for_text_not_visible(TEXT, SELECTOR)
2279+
if not object_dict:
2280+
data = re.match(
2281+
r"""^(\s*)self\.wait_for_text_not_visible"""
2282+
r"""\(([\S\s]+),\s?(r?['"][\S\s]+['"])\)([\S\s]*)$""",
2283+
line,
2284+
)
2285+
else:
2286+
data = re.match(
2287+
r"""^(\s*)self\.wait_for_text_not_visible"""
2288+
r"""\(([\S\s]+),\s?([\S]+)\)([\S\s]*)$""",
2289+
line,
2290+
)
2291+
if data:
2292+
whitespace = data.group(1)
2293+
text = data.group(2)
2294+
selector = "%s" % data.group(3)
2295+
selector = remove_extra_slashes(selector)
2296+
page_selectors.append(selector)
2297+
comments = data.group(4)
2298+
command = """%sself.wait_for_text_not_visible(%s, %s)%s""" % (
2299+
whitespace,
2300+
text,
2301+
selector,
2302+
comments,
2303+
)
2304+
if selector_dict:
2305+
if add_comments:
2306+
comments = " # %s" % selector
2307+
selector = optimize_selector(selector)
2308+
if selector in selector_dict.keys():
2309+
selector_object = selector_dict[selector]
2310+
changed.append(selector_object.split(".")[0])
2311+
command = "%sself.wait_for_text_not_visible(%s, %s)%s" % (
2312+
whitespace,
2313+
text,
2314+
selector_object,
2315+
comments,
2316+
)
2317+
if object_dict:
2318+
if not add_comments:
2319+
comments = ""
2320+
object_name = selector
2321+
if object_name in object_dict.keys():
2322+
selector_object = object_dict[object_name]
2323+
changed.append(object_name.split(".")[0])
2324+
command = "%sself.wait_for_text_not_visible(%s, %s)%s" % (
2325+
whitespace,
2326+
text,
2327+
selector_object,
2328+
comments,
2329+
)
2330+
seleniumbase_lines.append(command)
2331+
continue
2332+
22782333
# Handle if/elif self.is_element_*(SELECTOR): * = present/visible
22792334
if not object_dict:
22802335
data = re.match(

seleniumbase/utilities/selenium_ide/convert_ide.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
"""Converts a Selenium IDE recording that was exported as a Python WebDriver
2-
unittest file into SeleniumBase Python file.
3-
Works with Katalon Recorder scripts: http://www.katalon.com/automation-recorder
4-
1+
"""Converts a Selenium IDE recording that was exported as a
2+
Python WebDriver unittest file into SeleniumBase Python file.
3+
Also works with exported Katalon Recorder Selenium scripts:
4+
https://chrome.google.com/webstore/detail
5+
/katalon-recorder-selenium/ljdobmomdgdljniojadhoplhkpialdid
56
Usage:
67
seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE].py
7-
(run from anywhere)
8-
OR
9-
python convert_ide.py [PYTHON_WEBDRIVER_UNITTEST_FILE].py
10-
(when run from the "selenium_ide/" folder)
118
Output:
129
[NEW_FILE_SB].py (adds "_SB" to the original file name)
1310
(the original file is kept intact)"""
@@ -54,7 +51,8 @@ def main():
5451

5552
seleniumbase_lines = []
5653
seleniumbase_lines.append("from seleniumbase import BaseCase")
57-
seleniumbase_lines.append("") # Flake8 is very specific on whitespace
54+
seleniumbase_lines.append("BaseCase.main(__name__, __file__)")
55+
seleniumbase_lines.append("") # flake8 needs the whitespace
5856
seleniumbase_lines.append("")
5957

6058
ide_base_url = ""

0 commit comments

Comments
 (0)