python3+selenium 牛刀小试

 1 # coding:utf-8
 2 # __author__ = 'Carry'
 3 
 4 import unittest
 5 from selenium import webdriver
 6 import time
 7 
 8 class Test_bokeyuan(unittest.TestCase):
 9 
10     @classmethod
11     def setUpClass(cls):
12         cls.driver = webdriver.Chrome()
13 
14     def setUp(self):
15         self.driver.get("https://www.cnblogs.com/lxs1314/")
16 
17 
18     def test_a(self):
19         t = self.driver.title
20         print(t)
21         self.assertIn("杀手", t)
22 
23 
24     def test_b(self):
25         t = self.driver.title
26         print(t)
27         self.assertIn("彩笔", t)
28 
29     def test_c(self):
30         t = self.driver.title
31         print(t)
32         self.assertIn("彩笔杀手lalala", t)
33 
34     @classmethod
35     def tearDownClass(cls):
36         cls.driver.quit()
37 
38 if __name__ == "__main__":
39     unittest.main()
View Code

 

成功了2个,失败了1个  

原文地址:https://www.cnblogs.com/lxs1314/p/8405120.html