zhangxj365 发表于 2019-10-16 16:00:25

你好,老是,我有个问题

老师 ,你好,你之前把登陆 和 仪表盘 分成了 2个页面 去写。现在 我想用 一个测试类 去加载2条case,这2条case一个和登陆有关 ,一个和仪表盘有关,如何不让代码启动2次浏览器。因为启动浏览器是写在setup里面的,2个testcase就会加载2次setup
http://www.atstudy.com/files/course/2019/07-22/18234624d4c0332363.png

学掌门网校 发表于 2019-10-16 16:04:07

把BaseTestCase的setUp和tearDown方法改成setUpClass和tearDownClass,如下

class BaseTestCase(unittest2.TestCase):
    @classmethod
    def setUpClass(self):
      self.driver = webdriver.Chrome()
      self.driver.implicitly_wait(5)

    @classmethod
    def tearDownClass(self):
      time.sleep(20)
页: [1]
查看完整版本: 你好,老是,我有个问题