Refactoring
This commit is contained in:
parent
881c7bbbab
commit
05416e086a
|
@ -22,9 +22,7 @@ def generate_gherkin(srt_actions):
|
|||
elif "'" not in action[2]:
|
||||
sb_actions.append("Open '%s'" % action[2])
|
||||
else:
|
||||
sb_actions.append(
|
||||
'Open "%s"' % action[2].replace('"', '\\"')
|
||||
)
|
||||
sb_actions.append('Open "%s"' % action[2].replace('"', '\\"'))
|
||||
elif action[0] == "f_url":
|
||||
if "%" in action[2] and python3:
|
||||
try:
|
||||
|
@ -73,27 +71,17 @@ def generate_gherkin(srt_actions):
|
|||
method = "js_type"
|
||||
text = action[2].replace("\n", "\\n")
|
||||
if '"' not in action[1] and '"' not in text:
|
||||
sb_actions.append(
|
||||
'Into "%s" type "%s"' % (action[1], text)
|
||||
)
|
||||
sb_actions.append('Into "%s" type "%s"' % (action[1], text))
|
||||
elif '"' not in action[1] and '"' in text:
|
||||
sb_actions.append(
|
||||
'Into "%s" type \'%s\'' % (action[1], text)
|
||||
)
|
||||
sb_actions.append('Into "%s" type \'%s\'' % (action[1], text))
|
||||
elif '"' in action[1] and '"' not in text:
|
||||
sb_actions.append(
|
||||
'Into \'%s\' type "%s"' % (action[1], text)
|
||||
)
|
||||
sb_actions.append('Into \'%s\' type "%s"' % (action[1], text))
|
||||
elif '"' in action[1] and '"' in text:
|
||||
sb_actions.append(
|
||||
"Into '%s' type '%s'" % (action[1], text)
|
||||
)
|
||||
sb_actions.append("Into '%s' type '%s'" % (action[1], text))
|
||||
elif action[0] == "e_mfa":
|
||||
text = action[2].replace("\n", "\\n")
|
||||
if '"' not in action[1] and '"' not in text:
|
||||
sb_actions.append(
|
||||
'Into "%s" do MFA "%s"' % (action[1], text)
|
||||
)
|
||||
sb_actions.append('Into "%s" do MFA "%s"' % (action[1], text))
|
||||
elif '"' not in action[1] and '"' in text:
|
||||
sb_actions.append(
|
||||
'Into "%s" do MFA \'%s\'' % (action[1], text)
|
||||
|
@ -103,9 +91,7 @@ def generate_gherkin(srt_actions):
|
|||
'Into \'%s\' do MFA "%s"' % (action[1], text)
|
||||
)
|
||||
elif '"' in action[1] and '"' in text:
|
||||
sb_actions.append(
|
||||
"Into '%s' do MFA '%s'" % (action[1], text)
|
||||
)
|
||||
sb_actions.append("Into '%s' do MFA '%s'" % (action[1], text))
|
||||
elif action[0] == "h_clk":
|
||||
if '"' not in action[1] and '"' not in action[2]:
|
||||
sb_actions.append(
|
||||
|
@ -271,9 +257,7 @@ def generate_gherkin(srt_actions):
|
|||
if not dest:
|
||||
sb_actions.append('%s "%s" to downloads' % (method, file_url))
|
||||
else:
|
||||
sb_actions.append(
|
||||
'%s "%s" to "%s"' % (method, file_url, dest)
|
||||
)
|
||||
sb_actions.append('%s "%s" to "%s"' % (method, file_url, dest))
|
||||
elif action[0] == "as_at":
|
||||
if ('"' not in action[1][0]) and action[1][2]:
|
||||
sb_actions.append(
|
||||
|
@ -337,13 +321,9 @@ def generate_gherkin(srt_actions):
|
|||
)
|
||||
else:
|
||||
if '"' not in action[1][0]:
|
||||
sb_actions.append(
|
||||
'%s "%s"' % (method, action[1][0])
|
||||
)
|
||||
sb_actions.append('%s "%s"' % (method, action[1][0]))
|
||||
else:
|
||||
sb_actions.append(
|
||||
"%s '%s'" % (method, action[1][0])
|
||||
)
|
||||
sb_actions.append("%s '%s'" % (method, action[1][0]))
|
||||
elif action[0] == "da_el":
|
||||
method = "Deferred assert element"
|
||||
if '"' not in action[1]:
|
||||
|
|
|
@ -636,7 +636,7 @@ def get_configured_sb(context):
|
|||
sb.proxy_bypass_list = proxy_bypass_list
|
||||
continue
|
||||
# Handle: -D proxy-pac-url=URL / proxy-pac-url=USERNAME:PASSWORD@URL
|
||||
if low_key in ["proxy-pac-url", "proxy_pac_url", "pac-url", "pac_url"]:
|
||||
if low_key in ["proxy-pac-url", "pac-url"]:
|
||||
proxy_pac_url = userdata[key]
|
||||
if proxy_pac_url == "true":
|
||||
proxy_pac_url = sb.proxy_pac_url # revert to default
|
||||
|
|
|
@ -84,10 +84,7 @@ def do_behave_run(
|
|||
total_selected_tests += 1
|
||||
|
||||
full_run_command = "behave"
|
||||
if (
|
||||
total_selected_tests == 0
|
||||
or total_tests == total_selected_tests
|
||||
):
|
||||
if total_selected_tests == 0 or total_tests == total_selected_tests:
|
||||
if command_string:
|
||||
full_run_command += " "
|
||||
full_run_command += command_string
|
||||
|
@ -192,27 +189,19 @@ def create_tkinter_gui(tests, command_string):
|
|||
question_menu.pack()
|
||||
|
||||
qmx = tk.IntVar()
|
||||
chk = tk.Checkbutton(
|
||||
root, text="Quiet Mode (--quiet)", variable=qmx
|
||||
)
|
||||
chk = tk.Checkbutton(root, text="Quiet Mode (--quiet)", variable=qmx)
|
||||
chk.pack()
|
||||
|
||||
dmx = tk.IntVar()
|
||||
chk = tk.Checkbutton(
|
||||
root, text="Demo Mode (-D demo)", variable=dmx
|
||||
)
|
||||
chk = tk.Checkbutton(root, text="Demo Mode (-D demo)", variable=dmx)
|
||||
chk.pack()
|
||||
|
||||
mmx = tk.IntVar()
|
||||
chk = tk.Checkbutton(
|
||||
root, text="Mobile Mode (-D mobile)", variable=mmx
|
||||
)
|
||||
chk = tk.Checkbutton(root, text="Mobile Mode (-D mobile)", variable=mmx)
|
||||
chk.pack()
|
||||
|
||||
dbx = tk.IntVar()
|
||||
chk = tk.Checkbutton(
|
||||
root, text="Dashboard (-D dashboard)", variable=dbx
|
||||
)
|
||||
chk = tk.Checkbutton(root, text="Dashboard (-D dashboard)", variable=dbx)
|
||||
chk.pack()
|
||||
chk.select()
|
||||
|
||||
|
|
|
@ -83,10 +83,7 @@ def do_pytest_run(
|
|||
total_selected_tests += 1
|
||||
|
||||
full_run_command = "pytest"
|
||||
if (
|
||||
total_selected_tests == 0
|
||||
or total_tests == total_selected_tests
|
||||
):
|
||||
if total_selected_tests == 0 or total_tests == total_selected_tests:
|
||||
if command_string:
|
||||
full_run_command += " "
|
||||
full_run_command += command_string
|
||||
|
@ -195,28 +192,20 @@ def create_tkinter_gui(tests, command_string):
|
|||
question_menu.pack()
|
||||
|
||||
vox = tk.IntVar()
|
||||
chk = tk.Checkbutton(
|
||||
root, text="Verbose Output (-v)", variable=vox
|
||||
)
|
||||
chk = tk.Checkbutton(root, text="Verbose Output (-v)", variable=vox)
|
||||
chk.pack()
|
||||
chk.select()
|
||||
|
||||
dmx = tk.IntVar()
|
||||
chk = tk.Checkbutton(
|
||||
root, text="Demo Mode (--demo)", variable=dmx
|
||||
)
|
||||
chk = tk.Checkbutton(root, text="Demo Mode (--demo)", variable=dmx)
|
||||
chk.pack()
|
||||
|
||||
mmx = tk.IntVar()
|
||||
chk = tk.Checkbutton(
|
||||
root, text="Mobile Mode (--mobile)", variable=mmx
|
||||
)
|
||||
chk = tk.Checkbutton(root, text="Mobile Mode (--mobile)", variable=mmx)
|
||||
chk.pack()
|
||||
|
||||
dbx = tk.IntVar()
|
||||
chk = tk.Checkbutton(
|
||||
root, text="Dashboard (--dashboard)", variable=dbx
|
||||
)
|
||||
chk = tk.Checkbutton(root, text="Dashboard (--dashboard)", variable=dbx)
|
||||
chk.pack()
|
||||
chk.select()
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ def show_already_recording_warning():
|
|||
messagebox.showwarning(
|
||||
"SeleniumBase Recorder: Already Running!",
|
||||
"Please finalize the active recording from the terminal\n"
|
||||
'where you opened the Recorder: Type "c" and hit Enter.'
|
||||
'where you opened the Recorder: Type "c" and hit Enter.',
|
||||
)
|
||||
|
||||
|
||||
|
@ -175,7 +175,7 @@ def do_playback(file_name, use_chrome, window, demo_mode=False):
|
|||
messagebox.showwarning(
|
||||
"SeleniumBase Recorder: Already Running!",
|
||||
"Please finalize the active recording from the terminal\n"
|
||||
'where you opened the Recorder: Type "c" and hit Enter.'
|
||||
'where you opened the Recorder: Type "c" and hit Enter.',
|
||||
)
|
||||
send_window_to_front(window)
|
||||
|
||||
|
@ -278,7 +278,7 @@ def show_still_running_warning():
|
|||
"SeleniumBase Recorder: Still Running!",
|
||||
"Please finalize the active recording from the terminal\n"
|
||||
'where you opened the Recorder: Type "c" and hit Enter.\n'
|
||||
"(Then you can safely close this alert.)"
|
||||
"(Then you can safely close this alert.)",
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1449,9 +1449,7 @@ class BaseCase(unittest.TestCase):
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
def set_attribute_all(
|
||||
self, selector, attribute, value, by="css selector"
|
||||
):
|
||||
def set_attribute_all(self, selector, attribute, value, by="css selector"):
|
||||
"""Same as set_attributes(), but using querySelectorAll naming scheme.
|
||||
This method uses JavaScript to set/update a common attribute.
|
||||
All matching selectors from querySelectorAll() are used.
|
||||
|
@ -3528,7 +3526,8 @@ class BaseCase(unittest.TestCase):
|
|||
|
||||
if not self.is_chromium():
|
||||
raise Exception(
|
||||
"The Recorder is only for Chromium browsers: (Chrome or Edge)")
|
||||
"The Recorder is only for Chromium browsers: (Chrome or Edge)"
|
||||
)
|
||||
url = self.driver.current_url
|
||||
if (
|
||||
url.startswith("data:") or url.startswith("about:")
|
||||
|
@ -11488,8 +11487,8 @@ class BaseCase(unittest.TestCase):
|
|||
m_y = y
|
||||
if center:
|
||||
element_rect = element.rect
|
||||
left_offset = element_rect['width'] / 2
|
||||
top_offset = element_rect['height'] / 2
|
||||
left_offset = element_rect["width"] / 2
|
||||
top_offset = element_rect["height"] / 2
|
||||
m_x = left_offset + (m_x or 0)
|
||||
m_y = top_offset + (m_y or 0)
|
||||
px = m_x - 3
|
||||
|
@ -11516,8 +11515,8 @@ class BaseCase(unittest.TestCase):
|
|||
try:
|
||||
if selenium4_or_newer and not center:
|
||||
element_rect = element.rect
|
||||
left_offset = element_rect['width'] / 2
|
||||
top_offset = element_rect['height'] / 2
|
||||
left_offset = element_rect["width"] / 2
|
||||
top_offset = element_rect["height"] / 2
|
||||
x = -left_offset + (x or 0)
|
||||
y = -top_offset + (y or 0)
|
||||
elif selenium4_or_newer and center:
|
||||
|
@ -11527,8 +11526,8 @@ class BaseCase(unittest.TestCase):
|
|||
else:
|
||||
# not selenium4_or_newer and center:
|
||||
element_rect = element.rect
|
||||
left_offset = element_rect['width'] / 2
|
||||
top_offset = element_rect['height'] / 2
|
||||
left_offset = element_rect["width"] / 2
|
||||
top_offset = element_rect["height"] / 2
|
||||
x = left_offset + x
|
||||
y = top_offset + y
|
||||
action_chains = ActionChains(self.driver)
|
||||
|
|
|
@ -443,9 +443,7 @@ def pytest_addoption(parser):
|
|||
)
|
||||
parser.addoption(
|
||||
"--proxy-pac-url",
|
||||
"--proxy_pac_url",
|
||||
"--pac-url",
|
||||
"--pac_url",
|
||||
action="store",
|
||||
dest="proxy_pac_url",
|
||||
default=None,
|
||||
|
@ -1321,7 +1319,7 @@ def pytest_configure(config):
|
|||
print(
|
||||
"\n Recorder Mode does NOT support multi-process mode (-n)!"
|
||||
'\n (DO NOT combine "--recorder" with "-n NUM_PROCESSES"!)'
|
||||
'\n (The Recorder WILL BE DISABLED during this run!)\n'
|
||||
"\n (The Recorder WILL BE DISABLED during this run!)\n"
|
||||
)
|
||||
sb_config.recorder_mode = False
|
||||
sb_config.recorder_ext = False
|
||||
|
|
|
@ -193,9 +193,7 @@ class SeleniumBrowser(Plugin):
|
|||
)
|
||||
parser.add_option(
|
||||
"--proxy-pac-url",
|
||||
"--proxy_pac_url",
|
||||
"--pac-url",
|
||||
"--pac_url",
|
||||
action="store",
|
||||
dest="proxy_pac_url",
|
||||
default=None,
|
||||
|
|
Loading…
Reference in New Issue