python之unittest的ui测试用例02_ddt与yaml的使用

之前写过web ui测试的简单用例python之unittest的ui测试用例01
接下来要慢慢增加一些要求精进代码:

(1)测试点增多,比如之前测试打开浏览器并输入字符进行检索,如果增加检索内容,比如测试浏览器检索英文、中文、法文等,当然可以写多个def test用例,只需要将send_keys(“python”)中的python换成其他检测内容即可,但是看起来会比较冗余,这里可以将各测试用例前后都会执行的相同操作放到setUp和tearDown中:


import unittest
from selenium import webdriver
import time

class testcase(unittest.TestCase):
	def setUp(self):
		self.driver = webdriver.Chrome() 
		self.driver.get("http://www.baidu.com") 
		
	def tearDown(self):
		self.driver.find_element("id","su").click() 
		time.sleep(4) 
		self.driver.quit() 

	def test_1(self): #测试用例输入英文
		self.driver.find_element("id","kw").send_keys("python") 

	def test_2(self): #测试用例输入中文
		self.driver.find_element("id","kw").send_keys("编程语言python") 

	def test_3(self): #测试用例输入法语
		self.driver.find_element("id"
  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值