from ddt import ddt,data,unpack
from selenium import webdriver
from selenium.webdriver.common.by import By
import time,unittest

"""
测试类前加修饰@ddt.ddt
case前加修饰@ddt.data() 相同的测试用例
@ddt.unpack 分解data的参数
"""
@ddt
class BaiduSearch(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
cls.driver = webdriver.Chrome()
cls.driver.maximize_window()
cls.driver.implicitly_wait(10)
cls.driver.get('http://www.baidu.com')

@classmethod
def tearDownClass(cls) -> None:
cls.driver.quit()

@data(['selenium','selenium_百度搜索'],
['python','python_百度搜索'],
['appium','appium_百度搜索'])
@unpack

def test_search_001(self,a,b):
self.driver.find_element(By.ID,'kw').send_keys(a)
time.sleep(1)
self.assertIn(a,b)

@data({'search':'python','assertText':'python_百度搜索'})
@unpack
def test_search_002(self,search,assertText):
self.driver.find_element(By.ID,'kw').send_keys(search)
time.sleep(1)
self.assertIn(search,assertText)

if __name__ == '__main__':
unittest.main(verbosity=2)

python之数据驱动ddt操作(方法四)的更多相关文章

  1. python之数据驱动ddt操作(方法三)

    import unittestfrom selenium import webdriverfrom selenium.webdriver.common.by import Byimport unitt ...

  2. python之数据驱动ddt操作(方法二)

    import unittestfrom ddt import ddt,unpack,datafrom selenium import webdriverfrom selenium.webdriver. ...

  3. python之数据驱动ddt操作(方法一)

    下载ddt并安装 Pip install ddt 或者官网下载安装 http://ddt.readthedocs.io/en/latest/ https://github.com/txels/ddt ...

  4. python之数据驱动ddt

    下载ddt并安装 Pip install ddt 或者官网下载安装 http://ddt.readthedocs.io/en/latest/ https://github.com/txels/ddt ...

  5. python接口测试-数据驱动-DDT

    DDT是python的第三方库,全名称为:Data-Driven/Decorated Tests. ddt安装 通过pip安装ddt模块,安装Python后,Python自带pip功能包 切换到Pyt ...

  6. python之数据驱动Txt操作

    一.新建数据Mail163.txt文本 二.Txt_Mail163.py脚本如下: import unittestfrom selenium import webdriverfrom selenium ...

  7. 【Python学习】函数参数传递方法四种(位置,关键字,默认值,包裹位置,包裹关键字传递)

    1. 位置传递: #--coding:utf-8-- def send(name,address): return 'package is sent to %s, located in %s' %(n ...

  8. python之数据驱动Excel操作(方法一)

    一.Mail163.xlsx数据如下: 二.Mail163.py脚本如下 import xlrdimport unittestfrom selenium import webdriverfrom se ...

  9. python之数据驱动yaml操作

    Mail163.yaml配置文件如下: login_data: url : 'https://mail.163.com/'case1: user : '' passwd : '' errorText ...

随机推荐

  1. nvGRAPH API参考分析(一)

    nvGRAPH API参考分析(一) 本文通过描述nvGRAPH库函数的输入/输出参数,数据类型和错误代码来指定其行为. 1.    返回值nvgraphStatus_t 除以下内容外,所有nvGRA ...

  2. 电阻存储器为edge-AI提供了仿生架构

    电阻存储器为edge-AI提供了仿生架构 Resistive memories enable bio-inspired architectures for edge AI 近年来,脑启发计算领域的研究 ...

  3. vue中dom节点转图片

    今天项目中有个需求,需要将页面的一部分转为图片,相当于存证之类的 然后我查阅了下百度,发现了几种可行的方法,特此来记录下 1.html2canvas插件 安装:npm install --save h ...

  4. 瞎搞!你真的懂什么是ERP、中台和低代码吗?

    欢迎关注微信公众号:sap_gui (ERP咨询顾问之家) 互联网信息圈就是这样,写个不知所云的文章,再配上博眼球的标题,立马引来众多围观,不少公众号也蜂拥转载,完全不去思考文章写得对不对,有没有道理 ...

  5. ES6函数参数

    之前在看Vue2.0的时候,就被很多的箭头函数困扰,一直不知道是怎么回事,虽然箭头函数四个字在我耳边一直转圈,今天小编整理整理箭头函数里面的常见用法和表现形式,在这个Vue3.0已经到来的一段时间,希 ...

  6. Centos flock 防止脚本重复运行

    如果crontab设定任务每分钟执行一次,但执行的任务需要花费5分钟,这时系统会再执行导致两个相同的任务在执行.发生这种情况下可能会出现一些并发问题,严重时会导致出现脏数据性能瓶颈等恶性循环.为了防止 ...

  7. 量子:基于ERP块对的两步量子直接通信

    学习论文: 题目:Two-step quantum direct communication protocol using the Einstein-Podolsky-Rosen pair block ...

  8. 【NX二次开发】Block UI 选择小平面区域

    属性说明 属性   类型   描述   常规           BlockID    String    控件ID    Enable    Logical    是否可操作    Group    ...

  9. UF_CSYS 坐标系操作

    Open C   UF_CSYS_ask_csys_info               获取WCS坐标系的原点坐标和矩阵标识UF_CSYS_ask_matrix_of_object    获得对象 ...

  10. StringUtils中的常量

    //空格字符串 public static final String SPACE = " "; //空字符串 public static final String EMPTY = ...