11
11
12
12
Options:
13
13
-b / --basic (Basic boilerplate / single-line test)
14
+ -r / --recorder (Recorder Mode has ipdb breakpoint)
14
15
15
16
Language Options:
16
17
--en / --English | --zh / --Chinese
39
40
def invalid_run_command (msg = None ):
40
41
exp = " ** mkfile **\n \n "
41
42
exp += " Usage:\n "
42
- exp += " seleniumbase mkfile [FILE.py] [OPTIONS]\n "
43
- exp += " OR sbase mkfile [FILE.py] [OPTIONS]\n "
43
+ exp += " seleniumbase mkfile [FILE.py] [OPTIONS]\n "
44
+ exp += " OR sbase mkfile [FILE.py] [OPTIONS]\n "
44
45
exp += " Example:\n "
45
- exp += " sbase mkfile new_test.py\n "
46
+ exp += " sbase mkfile new_test.py\n "
46
47
exp += " Options:\n "
47
- exp += " -b / --basic (Basic boilerplate / single-line test)\n "
48
+ exp += " -b / --basic (Basic boilerplate / single-line test)\n "
49
+ exp += " -r / --recorder (Recorder Mode has ipdb breakpoint)\n "
48
50
exp += " Language Options:\n "
49
- exp += " --en / --English | --zh / --Chinese\n "
50
- exp += " --nl / --Dutch | --fr / --French\n "
51
- exp += " --it / --Italian | --ja / --Japanese\n "
52
- exp += " --ko / --Korean | --pt / --Portuguese\n "
53
- exp += " --ru / --Russian | --es / --Spanish\n "
51
+ exp += " --en / --English | --zh / --Chinese\n "
52
+ exp += " --nl / --Dutch | --fr / --French\n "
53
+ exp += " --it / --Italian | --ja / --Japanese\n "
54
+ exp += " --ko / --Korean | --pt / --Portuguese\n "
55
+ exp += " --ru / --Russian | --es / --Spanish\n "
54
56
exp += " Output:\n "
55
- exp += " Creates a new SBase test file with boilerplate code.\n "
56
- exp += " If the file already exists, an error is raised.\n "
57
- exp += " By default, uses English mode and creates a\n "
58
- exp += " boilerplate with the 5 most common SeleniumBase\n "
59
- exp += ' methods, which are "open", "type", "click",\n '
60
- exp += ' "assert_element", and "assert_text". If using the\n '
61
- exp += ' basic boilerplate option, only the "open" method\n '
62
- exp += " is included.\n "
57
+ exp += " Creates a new SBase test file with boilerplate code.\n "
58
+ exp += " If the file already exists, an error is raised.\n "
59
+ exp += " By default, uses English mode and creates a\n "
60
+ exp += " boilerplate with the 5 most common SeleniumBase\n "
61
+ exp += ' methods, which are "open", "type", "click",\n '
62
+ exp += ' "assert_element", and "assert_text". If using the\n '
63
+ exp += ' basic boilerplate option, only the "open" method\n '
64
+ exp += " is included.\n "
63
65
if not msg :
64
66
raise Exception ("INVALID RUN COMMAND!\n \n %s" % exp )
65
67
elif msg == "help" :
@@ -83,6 +85,7 @@ def main():
83
85
84
86
basic = False
85
87
help_me = False
88
+ recorder = False
86
89
error_msg = None
87
90
invalid_cmd = None
88
91
language = "English"
@@ -113,6 +116,10 @@ def main():
113
116
help_me = True
114
117
elif option == "-b" or option == "--basic" :
115
118
basic = True
119
+ elif option == "-r" or option == "--rec" :
120
+ recorder = True
121
+ elif option == "--record" or option == "--recorder" :
122
+ recorder = True
116
123
elif option == "--en" or option == "--english" :
117
124
language = "English"
118
125
elif option == "--zh" or option == "--chinese" :
@@ -155,8 +162,9 @@ def main():
155
162
dir_name = os .getcwd ()
156
163
file_path = "%s/%s" % (dir_name , file_name )
157
164
158
- body = "html > body"
159
- para = "body p"
165
+ body = "body"
166
+ para1 = "html body > p"
167
+ para2 = "p"
160
168
hello = "Hello"
161
169
goodbye = "Goodbye"
162
170
class_name = "MyTestClass"
@@ -200,9 +208,9 @@ def main():
200
208
if basic :
201
209
url = "about:blank"
202
210
elif language not in ["English" , "Dutch" , "French" , "Italian" ]:
203
- url = "data:text/html,<meta charset='utf-8'><p>%s <input>" % hello
211
+ url = "data:text/html,<meta charset='utf-8'><p>%s<br> <input>" % hello
204
212
else :
205
- url = "data:text/html,<p>%s<br><input></p> " % hello
213
+ url = "data:text/html,<p>%s<br><input>" % hello
206
214
207
215
import_line = "from seleniumbase import BaseCase"
208
216
parent_class = "BaseCase"
@@ -220,16 +228,20 @@ def main():
220
228
data .append ("" )
221
229
data .append ("%s" % class_line )
222
230
data .append (" def test_base(self):" )
223
- data .append (' self.open("%s")' % url )
224
- if not basic :
231
+ if not recorder :
232
+ data .append (' self.open("%s")' % url )
233
+ else :
234
+ data .append (' if self.recorder_ext and not self.xvfb:' )
235
+ data .append (' import ipdb; ipdb.set_trace()' )
236
+ if not basic and not recorder :
225
237
data .append (
226
238
' self.type("input", "%s")' " # selector, text" % goodbye
227
239
)
228
- data .append (' self.click("%s") # selector' % para )
240
+ data .append (' self.click("%s") # selector' % para1 )
229
241
data .append (' self.assert_element("%s") # selector' % body )
230
242
data .append (
231
243
' self.assert_text("%s", "%s")'
232
- " # text, selector" % (hello , para )
244
+ " # text, selector" % (hello , para2 )
233
245
)
234
246
data .append ("" )
235
247
@@ -271,6 +283,7 @@ def main():
271
283
file = codecs .open (file_path , "w+" , "utf-8" )
272
284
file .writelines ("\r \n " .join (data ))
273
285
file .close ()
286
+ os .system ("sbase print %s -n" % file_name )
274
287
success = (
275
288
"\n " + c1 + '* Test file: "' + file_name + '" was created! *'
276
289
"" + cr + "\n "
0 commit comments