Skip to content

Update GUI Apps and the HTML Inspector #1840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions help_docs/html_inspector.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ pytest test_inspect_html.py
⚠️ 'property' is not a valid attribute of the <meta> element.
⚠️ Do not use <div> or <span> elements without any attributes.
⚠️ 'srcset' is not a valid attribute of the <img> element.
⚠️ The 'border' attribute is no longer valid on the <img> element and should not be used.
⚠️ The <center> element is obsolete and should not be used.
⚠️ The 'border' attribute is no longer valid on the <img> element.
⚠️ The <center> element is obsolete.
⚠️ The id 'comicLinks' appears more than once in the document.
* (See the Console output for details!)
```
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.13.23"
__version__ = "4.13.24"
5 changes: 3 additions & 2 deletions seleniumbase/console_scripts/sb_behave_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def do_behave_run(
if selected_tests[selected_test].get():
total_selected_tests += 1

full_run_command = "behave"
full_run_command = "%s -m behave" % sys.executable
if total_selected_tests == 0 or total_tests == total_selected_tests:
if command_string:
full_run_command += " "
Expand Down Expand Up @@ -390,7 +390,8 @@ def main():
command_string = command_string.replace("--quiet", "")
command_string = command_string.replace("-q", "")
proc = subprocess.Popen(
"behave -d %s --show-source" % command_string,
"%s -m behave -d %s --show-source"
% (sys.executable, command_string),
stdout=subprocess.PIPE,
shell=True,
)
Expand Down
31 changes: 22 additions & 9 deletions seleniumbase/console_scripts/sb_caseplans.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@ def create_tkinter_gui(tests, command_string):
)
run_display_2 = "(Tests with existing Case Plans are already checked)"
tk.Label(root, text=run_display, fg="blue").pack()
tk.Label(root, text=run_display_2, fg="purple").pack()
try:
tk.Label(root, text=run_display_2, fg="purple").pack()
except Exception:
tk.Label(root, text=run_display_2, fg="magenta").pack()
text_area = ScrolledText(
root, width=100, height=12, wrap="word", state=tk.DISABLED
)
Expand Down Expand Up @@ -465,13 +468,22 @@ def create_tkinter_gui(tests, command_string):
).pack()

tk.Label(root, text="").pack()
tk.Button(
root,
text=(
"Generate Summary of existing Case Plans"),
fg="teal",
command=lambda: view_summary_of_existing_case_plans(root, tests),
).pack()
try:
tk.Button(
root,
text=(
"Generate Summary of existing Case Plans"),
fg="teal",
command=lambda: view_summary_of_existing_case_plans(root, tests),
).pack()
except Exception:
tk.Button(
root,
text=(
"Generate Summary of existing Case Plans"),
fg="green",
command=lambda: view_summary_of_existing_case_plans(root, tests),
).pack()
tk.Label(root, text="\n").pack()

# Bring form window to front
Expand Down Expand Up @@ -515,7 +527,8 @@ def main():
print(message)

proc = subprocess.Popen(
'pytest --co -q --rootdir="./" %s' % command_string,
'%s -m pytest --collect-only -q --rootdir="./" %s'
% (sys.executable, command_string),
stdout=subprocess.PIPE,
shell=True,
)
Expand Down
5 changes: 3 additions & 2 deletions seleniumbase/console_scripts/sb_commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def do_pytest_run(
if selected_tests[selected_test].get():
total_selected_tests += 1

full_run_command = "pytest"
full_run_command = "%s -m pytest" % sys.executable
if total_selected_tests == 0 or total_tests == total_selected_tests:
if command_string:
full_run_command += " "
Expand Down Expand Up @@ -424,7 +424,8 @@ def main():
print(message)

proc = subprocess.Popen(
'pytest --co -q --rootdir="./" %s' % command_string,
'%s -m pytest --collect-only -q --rootdir="./" %s'
% (sys.executable, command_string),
stdout=subprocess.PIPE,
shell=True,
)
Expand Down
22 changes: 7 additions & 15 deletions seleniumbase/console_scripts/sb_mkrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
import os
import sys

PLATFORM = sys.platform
IS_WINDOWS = False
if "win32" in PLATFORM or "win64" in PLATFORM or "x64" in PLATFORM:
IS_WINDOWS = True


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


def main():
platform = sys.platform
help_me = False
error_msg = None
invalid_cmd = None
Expand All @@ -99,7 +93,7 @@ def main():
force_gui = False
rec_behave = False

if "linux" in platform:
if "linux" in sys.platform:
use_colors = False
c0, c1, c2, c5, c7, cr = set_colors(use_colors)

Expand Down Expand Up @@ -142,7 +136,7 @@ def main():
elif option.lower() == "--edge":
use_edge = True
elif option.lower() in ("--gui", "--headed"):
if "linux" in platform:
if "linux" in sys.platform:
force_gui = True
elif option.lower() in ("--uc", "--undetected", "--undetectable"):
use_uc = True
Expand Down Expand Up @@ -189,9 +183,11 @@ def main():
print(success)
run_cmd = None
if not start_page:
run_cmd = "pytest %s --rec -q -s" % file_name
run_cmd = "%s -m pytest %s --rec -q -s" % (sys.executable, file_name)
else:
run_cmd = "pytest %s --rec -q -s --url=%s" % (file_name, start_page)
run_cmd = "%s -m pytest %s --rec -q -s --url=%s" % (
sys.executable, file_name, start_page
)
if use_edge:
run_cmd += " --edge"
if force_gui:
Expand All @@ -200,18 +196,14 @@ def main():
run_cmd += " --uc"
if rec_behave:
run_cmd += " --rec-behave"
if IS_WINDOWS:
run_cmd = "python.exe -m %s" % run_cmd
print(run_cmd)
os.system(run_cmd)
if os.path.exists(file_path):
os.remove(file_path)
recorded_filename = file_name[:-3] + "_rec.py"
recordings_dir = os.path.join(dir_name, "recordings")
recorded_file = os.path.join(recordings_dir, recorded_filename)
prefix = ""
if IS_WINDOWS:
prefix = "python.exe -m "
prefix = "%s -m " % sys.executable
if " " not in recorded_file:
os.system("%sseleniumbase print %s -n" % (prefix, recorded_file))
elif '"' not in recorded_file:
Expand Down
41 changes: 23 additions & 18 deletions seleniumbase/console_scripts/sb_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
from seleniumbase import config as sb_config
from seleniumbase.fixtures import page_utils

PLATFORM = sys.platform
IS_WINDOWS = False
if "win32" in PLATFORM or "win64" in PLATFORM or "x64" in PLATFORM:
IS_WINDOWS = True
sb_config.rec_subprocess_p = None
sb_config.rec_subprocess_used = False
if sys.version_info <= (3, 7):
Expand Down Expand Up @@ -134,9 +130,10 @@ def do_recording(file_name, url, overwrite_enabled, use_chrome, window):
or "--gherkin" in command_args
):
add_on = " --rec-behave"
command = "seleniumbase mkrec %s --url=%s --gui" % (file_name, url)
if IS_WINDOWS:
command = "python.exe -m %s" % command
command = (
"%s -m seleniumbase mkrec %s --url=%s --gui"
% (sys.executable, file_name, url)
)
if not use_chrome:
command += " --edge"
if (
Expand Down Expand Up @@ -171,9 +168,7 @@ def do_playback(file_name, use_chrome, window, demo_mode=False):
'File "%s" does not exist in the current directory!' % file_name,
)
return
command = "pytest %s -q -s" % file_name
if IS_WINDOWS:
command = "python.exe -m %s" % command
command = "%s -m pytest %s -q -s" % (sys.executable, file_name)
if "linux" in sys.platform:
command += " --gui"
if not use_chrome:
Expand Down Expand Up @@ -248,14 +243,24 @@ def create_tkinter_gui():
).pack()
tk.Label(window, text="").pack()
tk.Label(window, text="Playback recording (Demo Mode):").pack()
tk.Button(
window,
text="Playback (Demo Mode)",
fg="teal",
command=lambda: do_playback(
fname.get(), cbb.get(), window, demo_mode=True
),
).pack()
try:
tk.Button(
window,
text="Playback (Demo Mode)",
fg="teal",
command=lambda: do_playback(
fname.get(), cbb.get(), window, demo_mode=True
),
).pack()
except Exception:
tk.Button(
window,
text="Playback (Demo Mode)",
fg="blue",
command=lambda: do_playback(
fname.get(), cbb.get(), window, demo_mode=True
),
).pack()

# Bring form window to front
send_window_to_front(window)
Expand Down
8 changes: 7 additions & 1 deletion seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -7127,9 +7127,15 @@ def inspect_html(self):
if "0:6053 " in message:
message = message.split("0:6053")[1]
message = message.replace("\\u003C", "<")
message = message.replace(" and should not be used", "")
if message.startswith(' "') and message.count('"') == 2:
message = message.split('"')[1]
message = "⚠️ " + message
if "but not found in any stylesheet" in message:
continue
if not is_windows:
message = "⚠️ " + message
else:
message = "!-> " + message # CMD prompt compatibility
if messenger_library not in message:
if message not in results:
results.append(message)
Expand Down