chatgpt安装

当前位置: 主页 > chatgpt安装

学到了吗(pytest框架原理)pytest与unittest框架原理,chatgpt只用3秒钟就能写一个基于pytest的自动化框架,

时间:2023-04-20 00:21:30|栏目:chatgpt安装|点击:

chatgpt介面

下列是两个采用pytest架构展开腾讯登入介面智能化试验的实例标识符:

1.加装pytest

具体来说须要加装pytest,能采用下列指示展开加装:

pip install pytest

2.撰写单元试验

在工程项目产品目录下建立两个名叫 test_baidu_login.py 的文档,并撰写单元试验。比如,他们能撰写下列单元试验:

import pytest from selenium import webdriver @pytest.fixture(scope="module") def browser(): # 调用应用程序 driver = webdriver.Chrome() # 关上腾讯登入网页 driver.get("https://www.baidu.com") yield driver # 单元试验继续执行完后停用应用程序 driver.quit() def test_login_success(browser): # 输出帐号和公钥 browser.find_element_by_name("userName").send_keys("testuser") browser.find_element_by_name("password").send_keys("testpassword") # 点选登入按键 browser.find_element_by_id("loginBtn").click() # 判断登入是否成功 assert browser.title == "腾讯一下,你就知道" def test_login_failed(browser): # 输出错误的帐号和公钥 browser.find_element_by_name("userName").send_keys("wronguser") browser.find_element_by_name("password").send_keys("wrongpassword") # 点选登入按键 browser.find_element_by_id("loginBtn").click() # 判断登入是否失败 assert browser.title == "腾讯一下,你就知道"

在上述标识符中,他们采用了 pytest.fixture 来定义了两个应用程序的调用方法,使得每个单元试验都能共享同两个应用程序实例。同时,他们还撰写了两个单元试验,分别试验了正确和错误的帐号和公钥登入场景。

3.运行单元试验

完成单元试验撰写后,能采用下列指示来运行试验:

pytest test_baidu_login.py

运行完后,pytest会自动识别并继续执行他们撰写的单元试验,并输出试验结果。

上面就是用chatgpt完成的智能化标识符,整个过程就用了3五分钟。所以只要掌握好人工智能的采用那以后人人都是大牛,如果不与时俱进那就只有被淘汰了。

上一篇:暂无

栏    目:chatgpt安装

下一篇:深度揭秘(ai数据量化系统)ai量化技术服务,《跟我学习AI量化投资》通过chatgpt进行选股,简单易懂降低风险,

本文标题:学到了吗(pytest框架原理)pytest与unittest框架原理,chatgpt只用3秒钟就能写一个基于pytest的自动化框架,

本文地址:http://www.shopify123.cn/chatgptanzhuang/3625.html

| |

/uploads/allimg/20230913/1-230913232SH48.jpg

联系QQ:1303712368 | 邮箱:fy669088

Copyright © 2002-2024 ChatGPT-Sora-人工智能AI 版权所有桂ICP备2021004354号-4