3
3
Creates a new SeleniumBase test file using the Recorder.
4
4
5
5
Usage:
6
- seleniumbase mkrec [FILE.py]
7
- sbase mkrec [FILE.py]
8
- seleniumbase codegen [FILE.py]
9
- sbase codegen [FILE.py]
6
+ seleniumbase mkrec [FILE.py] [OPTIONS]
7
+ sbase mkrec [FILE.py] [OPTIONS]
8
+ seleniumbase codegen [FILE.py] [OPTIONS]
9
+ sbase codegen [FILE.py] [OPTIONS]
10
10
11
11
Examples:
12
12
sbase mkrec new_test.py
13
+ sbase mkrec new_test.py --url=seleniumbase.io
13
14
sbase codegen new_test.py
15
+ sbase codegen new_test.py --url=wikipedia.org
16
+
17
+ Options:
18
+ --url=URL (Sets the initial start page URL.)
19
+ --edge (Use Edge browser instead of Chrome.)
14
20
15
21
Output:
16
22
Creates a new SeleniumBase test using the Recorder.
@@ -34,6 +40,9 @@ def invalid_run_command(msg=None):
34
40
exp += " Examples:\n "
35
41
exp += " sbase mkrec new_test.py\n "
36
42
exp += " sbase codegen new_test.py\n "
43
+ exp += " Options:\n "
44
+ exp += " --url=URL (Sets the initial start page URL.)\n "
45
+ exp += " --edge (Use Edge browser instead of Chrome.)\n "
37
46
exp += " Output:\n "
38
47
exp += " Creates a new SeleniumBase test using the Recorder.\n "
39
48
exp += " If the filename already exists, an error is raised.\n "
@@ -65,6 +74,9 @@ def main():
65
74
help_me = False
66
75
error_msg = None
67
76
invalid_cmd = None
77
+ use_edge = False
78
+ start_page = None
79
+ next_is_url = False
68
80
69
81
command_args = sys .argv [2 :]
70
82
file_name = command_args [0 ]
@@ -87,9 +99,17 @@ def main():
87
99
if len (command_args ) >= 2 :
88
100
options = command_args [1 :]
89
101
for option in options :
90
- option = option .lower ()
91
- if option == "-h" or option == "--help" :
102
+ if option .lower () == "-h" or option .lower () == "--help" :
92
103
help_me = True
104
+ elif option .lower () == "--edge" :
105
+ use_edge = True
106
+ elif option .lower ().startswith ("--url=" ):
107
+ start_page = option [len ("--url=" ):]
108
+ elif option .lower () == "--url" :
109
+ next_is_url = True
110
+ elif next_is_url :
111
+ start_page = option
112
+ next_is_url = False
93
113
else :
94
114
invalid_cmd = "\n ===> INVALID OPTION: >> %s <<\n " % option
95
115
invalid_cmd = invalid_cmd .replace (">> " , ">>" + c5 + " " )
@@ -121,8 +141,18 @@ def main():
121
141
"" + c1 + file_name + "" + cr + "\n "
122
142
)
123
143
print (success )
124
- print ("pytest %s --rec -q -s" % file_name )
125
- os .system ("pytest %s --rec -q -s" % file_name )
144
+ if not start_page :
145
+ run_cmd = "pytest %s --rec -q -s" % file_name
146
+ if use_edge :
147
+ run_cmd += " --edge"
148
+ print (run_cmd )
149
+ os .system (run_cmd )
150
+ else :
151
+ run_cmd = "pytest %s --rec -q -s --url=%s" % (file_name , start_page )
152
+ if use_edge :
153
+ run_cmd += " --edge"
154
+ print (run_cmd )
155
+ os .system (run_cmd )
126
156
if os .path .exists (file_path ):
127
157
os .remove (file_path )
128
158
recorded_filename = file_name [:- 3 ] + "_rec.py"
0 commit comments