Skip to content

Commit 0b9276e

Browse files
committed
Update console scripts for page-object manipulation
1 parent 1afa44c commit 0b9276e

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

seleniumbase/utilities/selenium_ide/objectify.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,50 @@ def process_test_file(
618618
seleniumbase_lines.append(command)
619619
continue
620620

621+
# Handle self.set_value(SELECTOR, TEXT)
622+
if not object_dict:
623+
data = re.match(
624+
r'''^(\s*)self\.set_value'''
625+
r'''\(r?(['"][\S\s]+['"]),\s?(['"][\S\s]+['"])\)([\S\s]*)'''
626+
r'''$''', line)
627+
else:
628+
data = re.match(
629+
r'''^(\s*)self\.set_value'''
630+
r'''\(r?([\S\s]+),\s?(['"][\S\s]+['"])\)([\S\s]*)'''
631+
r'''$''', line)
632+
if data:
633+
raw = ""
634+
if "(r'" in line or '(r"' in line:
635+
raw = "r"
636+
whitespace = data.group(1)
637+
selector = '%s' % data.group(2)
638+
selector = remove_extra_slashes(selector)
639+
page_selectors.append(selector)
640+
text = data.group(3)
641+
comments = data.group(4)
642+
command = '''%sself.set_value(%s%s, %s)%s''' % (
643+
whitespace, raw, selector, text, comments)
644+
if selector_dict:
645+
if add_comments:
646+
comments = " # %s" % selector
647+
selector = optimize_selector(selector)
648+
if selector in selector_dict.keys():
649+
selector_object = selector_dict[selector]
650+
changed.append(selector_object.split('.')[0])
651+
command = '''%sself.set_value(%s, %s)%s''' % (
652+
whitespace, selector_object, text, comments)
653+
if object_dict:
654+
if not add_comments:
655+
comments = ""
656+
object_name = selector
657+
if object_name in object_dict.keys():
658+
selector_object = object_dict[object_name]
659+
changed.append(object_name.split('.')[0])
660+
command = '''%sself.set_value(%s, %s)%s''' % (
661+
whitespace, selector_object, text, comments)
662+
seleniumbase_lines.append(command)
663+
continue
664+
621665
# Handle self.assert_text(TEXT, SELECTOR)
622666
if not object_dict:
623667
data = re.match(

0 commit comments

Comments
 (0)