Skip to content

Commit 299cc2c

Browse files
authored
Merge pull request #1840 from seleniumbase/update-gui-apps-and-html-inspector
Update GUI Apps and the HTML Inspector
2 parents 18b18f9 + 2a5b6a9 commit 299cc2c

File tree

8 files changed

+68
-50
lines changed

8 files changed

+68
-50
lines changed

help_docs/html_inspector.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ pytest test_inspect_html.py
2828
⚠️ 'property' is not a valid attribute of the <meta> element.
2929
⚠️ Do not use <div> or <span> elements without any attributes.
3030
⚠️ 'srcset' is not a valid attribute of the <img> element.
31-
⚠️ The 'border' attribute is no longer valid on the <img> element and should not be used.
32-
⚠️ The <center> element is obsolete and should not be used.
31+
⚠️ The 'border' attribute is no longer valid on the <img> element.
32+
⚠️ The <center> element is obsolete.
3333
⚠️ The id 'comicLinks' appears more than once in the document.
3434
* (See the Console output for details!)
3535
```

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.13.23"
2+
__version__ = "4.13.24"

seleniumbase/console_scripts/sb_behave_gui.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def do_behave_run(
8181
if selected_tests[selected_test].get():
8282
total_selected_tests += 1
8383

84-
full_run_command = "behave"
84+
full_run_command = "%s -m behave" % sys.executable
8585
if total_selected_tests == 0 or total_tests == total_selected_tests:
8686
if command_string:
8787
full_run_command += " "
@@ -390,7 +390,8 @@ def main():
390390
command_string = command_string.replace("--quiet", "")
391391
command_string = command_string.replace("-q", "")
392392
proc = subprocess.Popen(
393-
"behave -d %s --show-source" % command_string,
393+
"%s -m behave -d %s --show-source"
394+
% (sys.executable, command_string),
394395
stdout=subprocess.PIPE,
395396
shell=True,
396397
)

seleniumbase/console_scripts/sb_caseplans.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,10 @@ def create_tkinter_gui(tests, command_string):
391391
)
392392
run_display_2 = "(Tests with existing Case Plans are already checked)"
393393
tk.Label(root, text=run_display, fg="blue").pack()
394-
tk.Label(root, text=run_display_2, fg="purple").pack()
394+
try:
395+
tk.Label(root, text=run_display_2, fg="purple").pack()
396+
except Exception:
397+
tk.Label(root, text=run_display_2, fg="magenta").pack()
395398
text_area = ScrolledText(
396399
root, width=100, height=12, wrap="word", state=tk.DISABLED
397400
)
@@ -465,13 +468,22 @@ def create_tkinter_gui(tests, command_string):
465468
).pack()
466469

467470
tk.Label(root, text="").pack()
468-
tk.Button(
469-
root,
470-
text=(
471-
"Generate Summary of existing Case Plans"),
472-
fg="teal",
473-
command=lambda: view_summary_of_existing_case_plans(root, tests),
474-
).pack()
471+
try:
472+
tk.Button(
473+
root,
474+
text=(
475+
"Generate Summary of existing Case Plans"),
476+
fg="teal",
477+
command=lambda: view_summary_of_existing_case_plans(root, tests),
478+
).pack()
479+
except Exception:
480+
tk.Button(
481+
root,
482+
text=(
483+
"Generate Summary of existing Case Plans"),
484+
fg="green",
485+
command=lambda: view_summary_of_existing_case_plans(root, tests),
486+
).pack()
475487
tk.Label(root, text="\n").pack()
476488

477489
# Bring form window to front
@@ -515,7 +527,8 @@ def main():
515527
print(message)
516528

517529
proc = subprocess.Popen(
518-
'pytest --co -q --rootdir="./" %s' % command_string,
530+
'%s -m pytest --collect-only -q --rootdir="./" %s'
531+
% (sys.executable, command_string),
519532
stdout=subprocess.PIPE,
520533
shell=True,
521534
)

seleniumbase/console_scripts/sb_commander.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def do_pytest_run(
9393
if selected_tests[selected_test].get():
9494
total_selected_tests += 1
9595

96-
full_run_command = "pytest"
96+
full_run_command = "%s -m pytest" % sys.executable
9797
if total_selected_tests == 0 or total_tests == total_selected_tests:
9898
if command_string:
9999
full_run_command += " "
@@ -424,7 +424,8 @@ def main():
424424
print(message)
425425

426426
proc = subprocess.Popen(
427-
'pytest --co -q --rootdir="./" %s' % command_string,
427+
'%s -m pytest --collect-only -q --rootdir="./" %s'
428+
% (sys.executable, command_string),
428429
stdout=subprocess.PIPE,
429430
shell=True,
430431
)

seleniumbase/console_scripts/sb_mkrec.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@
3535
import os
3636
import sys
3737

38-
PLATFORM = sys.platform
39-
IS_WINDOWS = False
40-
if "win32" in PLATFORM or "win64" in PLATFORM or "x64" in PLATFORM:
41-
IS_WINDOWS = True
42-
4338

4439
def invalid_run_command(msg=None):
4540
exp = " ** mkrec / record / codegen **\n\n"
@@ -87,7 +82,6 @@ def set_colors(use_colors):
8782

8883

8984
def main():
90-
platform = sys.platform
9185
help_me = False
9286
error_msg = None
9387
invalid_cmd = None
@@ -99,7 +93,7 @@ def main():
9993
force_gui = False
10094
rec_behave = False
10195

102-
if "linux" in platform:
96+
if "linux" in sys.platform:
10397
use_colors = False
10498
c0, c1, c2, c5, c7, cr = set_colors(use_colors)
10599

@@ -142,7 +136,7 @@ def main():
142136
elif option.lower() == "--edge":
143137
use_edge = True
144138
elif option.lower() in ("--gui", "--headed"):
145-
if "linux" in platform:
139+
if "linux" in sys.platform:
146140
force_gui = True
147141
elif option.lower() in ("--uc", "--undetected", "--undetectable"):
148142
use_uc = True
@@ -189,9 +183,11 @@ def main():
189183
print(success)
190184
run_cmd = None
191185
if not start_page:
192-
run_cmd = "pytest %s --rec -q -s" % file_name
186+
run_cmd = "%s -m pytest %s --rec -q -s" % (sys.executable, file_name)
193187
else:
194-
run_cmd = "pytest %s --rec -q -s --url=%s" % (file_name, start_page)
188+
run_cmd = "%s -m pytest %s --rec -q -s --url=%s" % (
189+
sys.executable, file_name, start_page
190+
)
195191
if use_edge:
196192
run_cmd += " --edge"
197193
if force_gui:
@@ -200,18 +196,14 @@ def main():
200196
run_cmd += " --uc"
201197
if rec_behave:
202198
run_cmd += " --rec-behave"
203-
if IS_WINDOWS:
204-
run_cmd = "python.exe -m %s" % run_cmd
205199
print(run_cmd)
206200
os.system(run_cmd)
207201
if os.path.exists(file_path):
208202
os.remove(file_path)
209203
recorded_filename = file_name[:-3] + "_rec.py"
210204
recordings_dir = os.path.join(dir_name, "recordings")
211205
recorded_file = os.path.join(recordings_dir, recorded_filename)
212-
prefix = ""
213-
if IS_WINDOWS:
214-
prefix = "python.exe -m "
206+
prefix = "%s -m " % sys.executable
215207
if " " not in recorded_file:
216208
os.system("%sseleniumbase print %s -n" % (prefix, recorded_file))
217209
elif '"' not in recorded_file:

seleniumbase/console_scripts/sb_recorder.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
from seleniumbase import config as sb_config
2222
from seleniumbase.fixtures import page_utils
2323

24-
PLATFORM = sys.platform
25-
IS_WINDOWS = False
26-
if "win32" in PLATFORM or "win64" in PLATFORM or "x64" in PLATFORM:
27-
IS_WINDOWS = True
2824
sb_config.rec_subprocess_p = None
2925
sb_config.rec_subprocess_used = False
3026
if sys.version_info <= (3, 7):
@@ -134,9 +130,10 @@ def do_recording(file_name, url, overwrite_enabled, use_chrome, window):
134130
or "--gherkin" in command_args
135131
):
136132
add_on = " --rec-behave"
137-
command = "seleniumbase mkrec %s --url=%s --gui" % (file_name, url)
138-
if IS_WINDOWS:
139-
command = "python.exe -m %s" % command
133+
command = (
134+
"%s -m seleniumbase mkrec %s --url=%s --gui"
135+
% (sys.executable, file_name, url)
136+
)
140137
if not use_chrome:
141138
command += " --edge"
142139
if (
@@ -171,9 +168,7 @@ def do_playback(file_name, use_chrome, window, demo_mode=False):
171168
'File "%s" does not exist in the current directory!' % file_name,
172169
)
173170
return
174-
command = "pytest %s -q -s" % file_name
175-
if IS_WINDOWS:
176-
command = "python.exe -m %s" % command
171+
command = "%s -m pytest %s -q -s" % (sys.executable, file_name)
177172
if "linux" in sys.platform:
178173
command += " --gui"
179174
if not use_chrome:
@@ -248,14 +243,24 @@ def create_tkinter_gui():
248243
).pack()
249244
tk.Label(window, text="").pack()
250245
tk.Label(window, text="Playback recording (Demo Mode):").pack()
251-
tk.Button(
252-
window,
253-
text="Playback (Demo Mode)",
254-
fg="teal",
255-
command=lambda: do_playback(
256-
fname.get(), cbb.get(), window, demo_mode=True
257-
),
258-
).pack()
246+
try:
247+
tk.Button(
248+
window,
249+
text="Playback (Demo Mode)",
250+
fg="teal",
251+
command=lambda: do_playback(
252+
fname.get(), cbb.get(), window, demo_mode=True
253+
),
254+
).pack()
255+
except Exception:
256+
tk.Button(
257+
window,
258+
text="Playback (Demo Mode)",
259+
fg="blue",
260+
command=lambda: do_playback(
261+
fname.get(), cbb.get(), window, demo_mode=True
262+
),
263+
).pack()
259264

260265
# Bring form window to front
261266
send_window_to_front(window)

seleniumbase/fixtures/base_case.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7127,9 +7127,15 @@ def inspect_html(self):
71277127
if "0:6053 " in message:
71287128
message = message.split("0:6053")[1]
71297129
message = message.replace("\\u003C", "<")
7130+
message = message.replace(" and should not be used", "")
71307131
if message.startswith(' "') and message.count('"') == 2:
71317132
message = message.split('"')[1]
7132-
message = "⚠️ " + message
7133+
if "but not found in any stylesheet" in message:
7134+
continue
7135+
if not is_windows:
7136+
message = "⚠️ " + message
7137+
else:
7138+
message = "!-> " + message # CMD prompt compatibility
71337139
if messenger_library not in message:
71347140
if message not in results:
71357141
results.append(message)

0 commit comments

Comments
 (0)