@@ -158,6 +158,19 @@ def main():
158
158
seleniumbase_lines .append (command )
159
159
continue
160
160
161
+ # Handle .find_element_by_id() + .submit()
162
+ data = re .match (
163
+ r'''^(\s*)driver\.find_element_by_id\(\"(\S+)\"\)'''
164
+ r'''\.submit\(\)\s*$''' , line )
165
+ if data :
166
+ whitespace = data .group (1 )
167
+ selector = '#%s' % data .group (2 ).replace ('#' , '\\ #' )
168
+ selector = selector .replace ('[' , '\\ [' ).replace (']' , '\\ ]' )
169
+ selector = selector .replace ('.' , '\\ .' )
170
+ command = '''%sself.submit('%s')''' % (whitespace , selector )
171
+ seleniumbase_lines .append (command )
172
+ continue
173
+
161
174
# Handle .find_element_by_id() + .send_keys()
162
175
data = re .match (
163
176
r'''^(\s*)driver\.find_element_by_id\(\"(\S+)\"\)'''
@@ -200,6 +213,17 @@ def main():
200
213
seleniumbase_lines .append (command )
201
214
continue
202
215
216
+ # Handle .find_element_by_name() + .submit()
217
+ data = re .match (
218
+ r'''^(\s*)driver\.find_element_by_name\(\"(\S+)\"\)'''
219
+ r'''\.submit\(\)\s*$''' , line )
220
+ if data :
221
+ whitespace = data .group (1 )
222
+ selector = '[name="%s"]' % data .group (2 )
223
+ command = '''%sself.submit('%s')''' % (whitespace , selector )
224
+ seleniumbase_lines .append (command )
225
+ continue
226
+
203
227
# Handle .find_element_by_name() + .send_keys()
204
228
data = re .match (
205
229
r'''^(\s*)driver\.find_element_by_name\(\"(\S+)\"\)'''
@@ -240,6 +264,19 @@ def main():
240
264
seleniumbase_lines .append (command )
241
265
continue
242
266
267
+ # Handle .find_element_by_css_selector() + .submit()
268
+ data = re .match (
269
+ r'''^(\s*)driver\.find_element_by_css_selector\(\"([\S\s]+)\"\)'''
270
+ r'''\.submit\(\)\s*$''' , line )
271
+ if data :
272
+ whitespace = data .group (1 )
273
+ selector = '%s' % data .group (2 )
274
+ command = '''%sself.submit('%s')''' % (whitespace , selector )
275
+ if command .count ('\\ "' ) == command .count ('"' ):
276
+ command = command .replace ('\\ "' , '"' )
277
+ seleniumbase_lines .append (command )
278
+ continue
279
+
243
280
# Handle .find_element_by_css_selector() + .send_keys()
244
281
data = re .match (
245
282
r'''^(\s*)driver\.find_element_by_css_selector\(\"([\S\s]+)\"\)'''
@@ -384,6 +421,22 @@ def main():
384
421
seleniumbase_lines .append (command )
385
422
continue
386
423
424
+ # Handle .find_element_by_xpath() + .submit()
425
+ data = re .match (
426
+ r'''^(\s*)driver\.find_element_by_xpath\(u?\"([\S\s]+)\"\)'''
427
+ r'''\.submit\(\)\s*$''' , line )
428
+ if data :
429
+ whitespace = data .group (1 )
430
+ xpath = '%s' % data .group (2 )
431
+ uni = ""
432
+ if '(u"' in line :
433
+ uni = "u"
434
+ has_unicode = True
435
+ command = '''%sself.submit(%s"%s")''' % (
436
+ whitespace , uni , xpath )
437
+ seleniumbase_lines .append (command )
438
+ continue
439
+
387
440
# Handle .find_element_by_link_text() + .click()
388
441
data = re .match (
389
442
r'''^(\s*)driver\.find_element_by_link_text\(u?\"([\S\s]+)\"\)'''
0 commit comments