Skip to content

Commit e28a958

Browse files
authored
Merge pull request #1043 from jsaponara/master
Allow for the ``sbase mkrec`` command to be run on headed Ubuntu machines.
2 parents 727db02 + 6bb70f9 commit e28a958

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

seleniumbase/console_scripts/sb_mkrec.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +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 += " --gui / --headed (Use headed mode on Linux.)\n"
4647
exp += " Output:\n"
4748
exp += " Creates a new SeleniumBase test using the Recorder.\n"
4849
exp += " If the filename already exists, an error is raised.\n"
@@ -55,28 +56,37 @@ def invalid_run_command(msg=None):
5556
raise Exception("INVALID RUN COMMAND!\n\n%s\n%s\n" % (exp, msg))
5657

5758

58-
def main():
59+
def set_colors(use_colors):
5960
c0 = ""
6061
c1 = ""
6162
c2 = ""
6263
c5 = ""
6364
c7 = ""
6465
cr = ""
65-
if "linux" not in sys.platform:
66+
if use_colors:
6667
colorama.init(autoreset=True)
6768
c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
6869
c1 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
6970
c2 = colorama.Fore.LIGHTRED_EX + colorama.Back.LIGHTYELLOW_EX
7071
c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
7172
c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA
7273
cr = colorama.Style.RESET_ALL
74+
return c0, c1, c2, c5, c7, cr
75+
7376

77+
def main():
7478
help_me = False
7579
error_msg = None
7680
invalid_cmd = None
7781
use_edge = False
7882
start_page = None
7983
next_is_url = False
84+
use_colors = True
85+
force_gui = False
86+
87+
if "linux" in sys.platform:
88+
use_colors = False
89+
c0, c1, c2, c5, c7, cr = set_colors(use_colors)
8090

8191
command_args = sys.argv[2:]
8292
file_name = command_args[0]
@@ -103,6 +113,13 @@ def main():
103113
help_me = True
104114
elif option.lower() == "--edge":
105115
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
106123
elif option.lower().startswith("--url="):
107124
start_page = option[len("--url="):]
108125
elif option.lower() == "--url":
@@ -145,12 +162,16 @@ def main():
145162
run_cmd = "pytest %s --rec -q -s" % file_name
146163
if use_edge:
147164
run_cmd += " --edge"
165+
if force_gui:
166+
run_cmd += " --gui"
148167
print(run_cmd)
149168
os.system(run_cmd)
150169
else:
151170
run_cmd = "pytest %s --rec -q -s --url=%s" % (file_name, start_page)
152171
if use_edge:
153172
run_cmd += " --edge"
173+
if force_gui:
174+
run_cmd += " --gui"
154175
print(run_cmd)
155176
os.system(run_cmd)
156177
if os.path.exists(file_path):

0 commit comments

Comments
 (0)