Skip to content

Commit b0dab25

Browse files
committed
toward running interactively under ubuntu.
1 parent cc5d6cc commit b0dab25

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

seleniumbase/console_scripts/sb_mkrec.py

Lines changed: 18 additions & 5 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 += " --ui or --headed (For linux: use browser instead of headless.)\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"
@@ -54,22 +55,25 @@ def invalid_run_command(msg=None):
5455
else:
5556
raise Exception("INVALID RUN COMMAND!\n\n%s\n%s\n" % (exp, msg))
5657

57-
58-
def main():
58+
def set_colors(use_colors):
5959
c0 = ""
6060
c1 = ""
6161
c2 = ""
6262
c5 = ""
6363
c7 = ""
6464
cr = ""
65-
if "linux" not in sys.platform:
65+
if use_colors:
6666
colorama.init(autoreset=True)
6767
c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
6868
c1 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
6969
c2 = colorama.Fore.LIGHTRED_EX + colorama.Back.LIGHTYELLOW_EX
7070
c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
7171
c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA
7272
cr = colorama.Style.RESET_ALL
73+
return c0, c1, c2, c5, c7, cr
74+
75+
76+
def main():
7377

7478
help_me = False
7579
error_msg = None
@@ -78,6 +82,9 @@ def main():
7882
start_page = None
7983
next_is_url = False
8084

85+
use_browser = ("linux" not in sys.platform)
86+
c0, c1, c2, c5, c7, cr = set_colors(use_browser)
87+
8188
command_args = sys.argv[2:]
8289
file_name = command_args[0]
8390
if file_name == "-h" or file_name == "--help":
@@ -110,6 +117,9 @@ def main():
110117
elif next_is_url:
111118
start_page = option
112119
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)
113123
else:
114124
invalid_cmd = "\n===> INVALID OPTION: >> %s <<\n" % option
115125
invalid_cmd = invalid_cmd.replace(">> ", ">>" + c5 + " ")
@@ -143,8 +153,11 @@ def main():
143153
print(success)
144154
if not start_page:
145155
run_cmd = "pytest %s --rec -q -s" % file_name
146-
if use_edge:
147-
run_cmd += " --edge"
156+
if use_browser:
157+
if use_edge:
158+
run_cmd += " --edge"
159+
else:
160+
run_cmd += " --chrome"
148161
print(run_cmd)
149162
os.system(run_cmd)
150163
else:

0 commit comments

Comments
 (0)