Skip to content

Commit bd374e5

Browse files
committed
Refactoring
1 parent 3df01b6 commit bd374e5

24 files changed

+485
-459
lines changed

seleniumbase/console_scripts/rich_helper.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ def fix_emoji_spacing(code):
3838
try:
3939
# Fix the display width of certain emojis that take up two spaces
4040
double_width_emojis = [
41-
"🗺️", "🖼️", "🗄️", "⏺️", "♻️", "🗂️", "🖥️", "🕹️", "🎞️"
41+
"🗺️",
42+
"🖼️",
43+
"🗄️",
44+
"⏺️",
45+
"♻️",
46+
"🗂️",
47+
"🖥️",
48+
"🕹️",
49+
"🎞️",
4250
]
4351
for emoji in double_width_emojis:
4452
if emoji in code:

seleniumbase/console_scripts/sb_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def main(override=None):
196196
use_version = url_request.text
197197
if get_latest_minus_one:
198198
get_v_latest = True
199-
use_version = str(int(use_version.split('.')[0]) - 1)
199+
use_version = str(int(use_version.split(".")[0]) - 1)
200200
if get_v_latest:
201201
url_req = requests_get(last)
202202
if url_req.ok:

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@ def main():
362362
data.append(' self.assert_text("Automation Practice", "h3")')
363363
data.append(" try:")
364364
data.append(" self.hover_and_click(")
365-
data.append(' "#myDropdown", "#dropOption2", timeout=2)')
365+
data.append(' "#myDropdown", "#dropOption2", timeout=1)')
366366
data.append(" except Exception:")
367-
data.append(" # If a human moves the mouse while the test runs")
367+
data.append(" # If someone moves the mouse while the test runs")
368368
data.append(' self.js_click("#dropOption2")')
369369
data.append(' self.assert_text("Link Two Selected", "h3")')
370370
data.append(' self.assert_text("This Text is Green", "#pText")')
@@ -412,7 +412,8 @@ def main():
412412
data.append(' self.assert_true(self.is_selected(".fBox"))')
413413
data.append(" self.switch_to_default_content()")
414414
data.append(
415-
' self.assert_element_not_visible("div#drop2 img#logo")')
415+
' self.assert_element_not_visible("div#drop2 img#logo")'
416+
)
416417
data.append(' self.drag_and_drop("img#logo", "div#drop2")')
417418
data.append(' self.assert_element("div#drop2 img#logo")')
418419
data.append(' self.assert_link_text("seleniumbase.com")')

seleniumbase/console_scripts/sb_mkfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ def main():
231231
if not recorder:
232232
data.append(' self.open("%s")' % url)
233233
else:
234-
data.append(' if self.recorder_ext and not self.xvfb:')
235-
data.append(' import ipdb; ipdb.set_trace()')
234+
data.append(" if self.recorder_ext and not self.xvfb:")
235+
data.append(" import ipdb; ipdb.set_trace()")
236236
if not basic and not recorder:
237237
data.append(
238238
' self.type("input", "%s")' " # selector, text" % goodbye

seleniumbase/console_scripts/sb_mkrec.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def main():
116116
file_path = os.path.join(dir_name, file_name)
117117

118118
if (
119-
"--overwrite" in ' '.join(command_args).lower()
119+
"--overwrite" in " ".join(command_args).lower()
120120
and os.path.exists(file_path)
121121
):
122122
os.remove(file_path)
@@ -132,9 +132,7 @@ def main():
132132
help_me = True
133133
elif option.lower() == "--edge":
134134
use_edge = True
135-
elif (
136-
option.lower() in ("--gui", "--headed")
137-
):
135+
elif option.lower() in ("--gui", "--headed"):
138136
if "linux" in platform:
139137
force_gui = True
140138
elif option.lower().startswith("--url="):
@@ -163,14 +161,14 @@ def main():
163161
data.append("")
164162
data.append("class RecorderTests(BaseCase):")
165163
data.append(" def test_recording(self):")
166-
data.append(' if self.recorder_ext and not self.xvfb:')
167-
data.append(' import ipdb; ipdb.set_trace()')
164+
data.append(" if self.recorder_ext and not self.xvfb:")
165+
data.append(" import ipdb; ipdb.set_trace()")
168166
data.append("")
169167
file = codecs.open(file_path, "w+", "utf-8")
170168
file.writelines("\r\n".join(data))
171169
file.close()
172170
success = (
173-
"\n" + c0 + '* RECORDING initialized:' + cr + " "
171+
"\n" + c0 + "* RECORDING initialized:" + cr + " "
174172
"" + c1 + file_name + "" + cr + "\n"
175173
)
176174
print(success)

seleniumbase/console_scripts/sb_print.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -595,12 +595,9 @@ def main():
595595
if use_rich and code_lang == "markdown" and not line_numbers:
596596
all_code = rich_helper.fix_emoji_spacing(all_code)
597597
all_code = all_code.replace("<br />", "\n")
598-
all_code = all_code.replace(
599-
'<p align="center">', '\n')
600-
all_code = all_code.replace(
601-
'<p align="left">', '\n')
602-
all_code = all_code.replace(
603-
'<p align="right">', '\n')
598+
all_code = all_code.replace('<p align="center">', "\n")
599+
all_code = all_code.replace('<p align="left">', "\n")
600+
all_code = all_code.replace('<p align="right">', "\n")
604601
all_code = all_code.replace("<p>", "\n")
605602
all_code = all_code.replace("</p>", "\n")
606603
if "<b>*" not in all_code and "*<b>" not in all_code:

seleniumbase/console_scripts/sb_recorder.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ def do_recording(file_name, url, overwrite_enabled, use_chrome, window):
6868
error_msg = file_name_error(file_name)
6969
if error_msg:
7070
messagebox.showwarning(
71-
"Invalid filename", "Invalid filename: %s" % error_msg)
71+
"Invalid filename", "Invalid filename: %s" % error_msg
72+
)
7273
return
7374

7475
url = url.strip()
@@ -77,14 +78,15 @@ def do_recording(file_name, url, overwrite_enabled, use_chrome, window):
7778
url = "https://" + url
7879
if not page_utils.is_valid_url(url):
7980
messagebox.showwarning(
80-
"Invalid URL", "Enter a valid URL! (Eg. seleniumbase.io)")
81+
"Invalid URL", "Enter a valid URL! (Eg. seleniumbase.io)"
82+
)
8183
else:
8284
if os.path.exists(os.getcwd() + "/" + file_name):
8385
if not overwrite_enabled:
8486
msgbox = tk.messagebox.askquestion(
8587
"Overwrite?",
8688
'Are you sure you want to overwrite "%s"?' % file_name,
87-
icon="warning"
89+
icon="warning",
8890
)
8991
if msgbox == "yes":
9092
os.remove(file_name)
@@ -105,12 +107,13 @@ def do_playback(file_name, use_chrome, window, demo_mode=False):
105107
error_msg = file_name_error(file_name)
106108
if error_msg:
107109
messagebox.showwarning(
108-
"Invalid filename", "Invalid filename: %s" % error_msg)
110+
"Invalid filename", "Invalid filename: %s" % error_msg
111+
)
109112
return
110113
if not os.path.exists(os.getcwd() + "/" + file_name):
111114
messagebox.showwarning(
112115
"File does not exist",
113-
'File "%s" does not exist in the current directory!' % file_name
116+
'File "%s" does not exist in the current directory!' % file_name,
114117
)
115118
return
116119
command = "pytest %s -q -s" % file_name
@@ -154,28 +157,38 @@ def create_tkinter_gui():
154157
entry.focus()
155158
entry.bind(
156159
"<Return>",
157-
(lambda _: do_recording(
158-
fname.get(), url.get(), cbx.get(), cbb.get(), window))
160+
(
161+
lambda _: do_recording(
162+
fname.get(), url.get(), cbx.get(), cbb.get(), window
163+
)
164+
),
159165
)
160166
tk.Button(
161-
window, text="Record", fg="red",
167+
window,
168+
text="Record",
169+
fg="red",
162170
command=lambda: do_recording(
163-
fname.get(), url.get(), cbx.get(), cbb.get(), window)
171+
fname.get(), url.get(), cbx.get(), cbb.get(), window
172+
),
164173
).pack()
165174
tk.Label(window, text="").pack()
166-
tk.Label(
167-
window, text="Playback recording (Normal Mode):").pack()
175+
tk.Label(window, text="Playback recording (Normal Mode):").pack()
168176
tk.Button(
169-
window, text="Playback", fg="green",
170-
command=lambda: do_playback(fname.get(), cbb.get(), window)
177+
window,
178+
text="Playback",
179+
fg="green",
180+
command=lambda: do_playback(fname.get(), cbb.get(), window),
171181
).pack()
172182
tk.Label(window, text="").pack()
173-
tk.Label(
174-
window, text="Playback recording (Demo Mode):").pack()
183+
tk.Label(window, text="Playback recording (Demo Mode):").pack()
175184
tk.Button(
176-
window, text="Playback (Demo Mode)", fg="teal",
185+
window,
186+
text="Playback (Demo Mode)",
187+
fg="teal",
177188
command=lambda: do_playback(
178-
fname.get(), cbb.get(), window, demo_mode=True)).pack()
189+
fname.get(), cbb.get(), window, demo_mode=True
190+
),
191+
).pack()
179192

180193
# Bring form window to front
181194
send_window_to_front(window)

0 commit comments

Comments
 (0)