@@ -230,16 +230,19 @@ def main():
230
230
data .append ("" )
231
231
data .append (" def test_basic(self):" )
232
232
data .append (' self.open("https://store.xkcd.com/search")' )
233
- data .append (" self.type('input[name=\" q\" ]', \" xkcd book\\ n\" )" )
233
+ data .append (" self.type('input[name=\" q\" ]', \" xkcd book\" )" )
234
+ data .append (" self.click('input[value=\" Search\" ]')" )
234
235
data .append (' self.assert_text("xkcd: volume 0", "h3")' )
235
236
data .append (' self.open("https://xkcd.com/353/")' )
236
237
data .append (' self.assert_title("xkcd: Python")' )
237
238
data .append (" self.assert_element('img[alt=\" Python\" ]')" )
238
239
data .append (" self.click('a[rel=\" license\" ]')" )
239
240
data .append (' self.assert_text("free to copy and reuse")' )
240
241
data .append (' self.go_back()' )
241
- data .append (' self.click("link= About")' )
242
+ data .append (' self.click_link_text(" About")' )
242
243
data .append (' self.assert_exact_text("xkcd.com", "h2")' )
244
+ data .append (' self.click_link_text("geohashing")' )
245
+ data .append (' self.assert_element("#comic img")' )
243
246
data .append ("" )
244
247
file_path = "%s/%s" % (dir_name , "my_first_test.py" )
245
248
file = codecs .open (file_path , "w+" , "utf-8" )
@@ -357,13 +360,26 @@ def main():
357
360
data .append ("class BaseTestCase(BaseCase):" )
358
361
data .append ("" )
359
362
data .append (" def setUp(self):" )
360
- data .append (" super(BaseTestCase, self).setUp()" )
361
- data .append (" # << Add custom code AFTER the super() line >>" )
363
+ if sys .version_info [0 ] >= 3 :
364
+ data .append (" super().setUp()" )
365
+ else :
366
+ data .append (" super(BaseTestCase, self).setUp()" )
367
+ data .append (" # <<< Run custom code AFTER the super() line >>>" )
362
368
data .append ("" )
363
369
data .append (" def tearDown(self):" )
364
370
data .append (" self.save_teardown_screenshot()" )
365
- data .append (" # << Add custom code BEFORE the super() line >>" )
366
- data .append (" super(BaseTestCase, self).tearDown()" )
371
+ data .append (" if self.has_exception():" )
372
+ data .append (" # <<< Run custom code if the test failed. >>>" )
373
+ data .append (" pass" )
374
+ data .append (" else:" )
375
+ data .append (" # <<< Run custom code if the test passed. >>>" )
376
+ data .append (" pass" )
377
+ data .append (" # (Wrap unreliable code in a try/except block.)" )
378
+ data .append (" # <<< Run custom code BEFORE the super() line >>>" )
379
+ if sys .version_info [0 ] >= 3 :
380
+ data .append (" super().tearDown()" )
381
+ else :
382
+ data .append (" super(BaseTestCase, self).tearDown()" )
367
383
data .append ("" )
368
384
data .append (" def login(self):" )
369
385
data .append (" # <<< Placeholder. Add your code here. >>>" )
0 commit comments