Skip to content

Commit 6bb70f9

Browse files
authored
Update sb_mkrec.py
1 parent b0dab25 commit 6bb70f9

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

seleniumbase/console_scripts/sb_mkrec.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def invalid_run_command(msg=None):
4343
exp += " Options:\n"
4444
exp += " --url=URL (Sets the initial start page URL.)\n"
4545
exp += " --edge (Use Edge browser instead of Chrome.)\n"
46-
exp += " --ui or --headed (For linux: use browser instead of headless.)\n"
46+
exp += " --gui / --headed (Use headed mode on Linux.)\n"
4747
exp += " Output:\n"
4848
exp += " Creates a new SeleniumBase test using the Recorder.\n"
4949
exp += " If the filename already exists, an error is raised.\n"
@@ -55,6 +55,7 @@ def invalid_run_command(msg=None):
5555
else:
5656
raise Exception("INVALID RUN COMMAND!\n\n%s\n%s\n" % (exp, msg))
5757

58+
5859
def set_colors(use_colors):
5960
c0 = ""
6061
c1 = ""
@@ -74,16 +75,18 @@ def set_colors(use_colors):
7475

7576

7677
def main():
77-
7878
help_me = False
7979
error_msg = None
8080
invalid_cmd = None
8181
use_edge = False
8282
start_page = None
8383
next_is_url = False
84+
use_colors = True
85+
force_gui = False
8486

85-
use_browser = ("linux" not in sys.platform)
86-
c0, c1, c2, c5, c7, cr = set_colors(use_browser)
87+
if "linux" in sys.platform:
88+
use_colors = False
89+
c0, c1, c2, c5, c7, cr = set_colors(use_colors)
8790

8891
command_args = sys.argv[2:]
8992
file_name = command_args[0]
@@ -110,16 +113,20 @@ def main():
110113
help_me = True
111114
elif option.lower() == "--edge":
112115
use_edge = True
116+
elif (
117+
option.lower() in ("--gui", "--headed")
118+
and "linux" in sys.platform
119+
):
120+
use_colors = True
121+
c0, c1, c2, c5, c7, cr = set_colors(use_colors)
122+
force_gui = True
113123
elif option.lower().startswith("--url="):
114124
start_page = option[len("--url="):]
115125
elif option.lower() == "--url":
116126
next_is_url = True
117127
elif next_is_url:
118128
start_page = option
119129
next_is_url = False
120-
elif option.lower() in ('--gui', '--headed'):
121-
use_browser = True
122-
c0, c1, c2, c5, c7, cr = set_colors(use_browser)
123130
else:
124131
invalid_cmd = "\n===> INVALID OPTION: >> %s <<\n" % option
125132
invalid_cmd = invalid_cmd.replace(">> ", ">>" + c5 + " ")
@@ -153,17 +160,18 @@ def main():
153160
print(success)
154161
if not start_page:
155162
run_cmd = "pytest %s --rec -q -s" % file_name
156-
if use_browser:
157-
if use_edge:
158-
run_cmd += " --edge"
159-
else:
160-
run_cmd += " --chrome"
163+
if use_edge:
164+
run_cmd += " --edge"
165+
if force_gui:
166+
run_cmd += " --gui"
161167
print(run_cmd)
162168
os.system(run_cmd)
163169
else:
164170
run_cmd = "pytest %s --rec -q -s --url=%s" % (file_name, start_page)
165171
if use_edge:
166172
run_cmd += " --edge"
173+
if force_gui:
174+
run_cmd += " --gui"
167175
print(run_cmd)
168176
os.system(run_cmd)
169177
if os.path.exists(file_path):

0 commit comments

Comments
 (0)