@@ -43,6 +43,7 @@ def invalid_run_command(msg=None):
43
43
exp += " Options:\n "
44
44
exp += " --url=URL (Sets the initial start page URL.)\n "
45
45
exp += " --edge (Use Edge browser instead of Chrome.)\n "
46
+ exp += " --gui / --headed (Use headed mode on Linux.)\n "
46
47
exp += " Output:\n "
47
48
exp += " Creates a new SeleniumBase test using the Recorder.\n "
48
49
exp += " If the filename already exists, an error is raised.\n "
@@ -55,28 +56,37 @@ def invalid_run_command(msg=None):
55
56
raise Exception ("INVALID RUN COMMAND!\n \n %s\n %s\n " % (exp , msg ))
56
57
57
58
58
- def main ( ):
59
+ def set_colors ( use_colors ):
59
60
c0 = ""
60
61
c1 = ""
61
62
c2 = ""
62
63
c5 = ""
63
64
c7 = ""
64
65
cr = ""
65
- if "linux" not in sys . platform :
66
+ if use_colors :
66
67
colorama .init (autoreset = True )
67
68
c0 = colorama .Fore .BLUE + colorama .Back .LIGHTCYAN_EX
68
69
c1 = colorama .Fore .RED + colorama .Back .LIGHTYELLOW_EX
69
70
c2 = colorama .Fore .LIGHTRED_EX + colorama .Back .LIGHTYELLOW_EX
70
71
c5 = colorama .Fore .RED + colorama .Back .LIGHTYELLOW_EX
71
72
c7 = colorama .Fore .BLACK + colorama .Back .MAGENTA
72
73
cr = colorama .Style .RESET_ALL
74
+ return c0 , c1 , c2 , c5 , c7 , cr
75
+
73
76
77
+ def main ():
74
78
help_me = False
75
79
error_msg = None
76
80
invalid_cmd = None
77
81
use_edge = False
78
82
start_page = None
79
83
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 )
80
90
81
91
command_args = sys .argv [2 :]
82
92
file_name = command_args [0 ]
@@ -103,6 +113,13 @@ def main():
103
113
help_me = True
104
114
elif option .lower () == "--edge" :
105
115
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
106
123
elif option .lower ().startswith ("--url=" ):
107
124
start_page = option [len ("--url=" ):]
108
125
elif option .lower () == "--url" :
@@ -145,12 +162,16 @@ def main():
145
162
run_cmd = "pytest %s --rec -q -s" % file_name
146
163
if use_edge :
147
164
run_cmd += " --edge"
165
+ if force_gui :
166
+ run_cmd += " --gui"
148
167
print (run_cmd )
149
168
os .system (run_cmd )
150
169
else :
151
170
run_cmd = "pytest %s --rec -q -s --url=%s" % (file_name , start_page )
152
171
if use_edge :
153
172
run_cmd += " --edge"
173
+ if force_gui :
174
+ run_cmd += " --gui"
154
175
print (run_cmd )
155
176
os .system (run_cmd )
156
177
if os .path .exists (file_path ):
0 commit comments