首页 > 其他分享 >selenium + 代码 进阶 (3)

selenium + 代码 进阶 (3)

时间:2022-10-12 10:45:00浏览次数:54  
标签:进阶 driver 代码 selenium TestCase test div unittest 测试方法

1.写一个测试用例   新建类,继承unittest.TestCase  -》导包-》写test方法

1 class TestCase(unittest.TestCase) //  1. 新建类继承unittest.TestCase 2导入uniitest
2         def test_01_login(self):  //3. 写test方法
3           driver = webdriver.Chrome()
4           driver.get("https://www.baidu.com/")
5           elem = driver.find_element(By.XPATH, "/html/body/div[1]/div[2]/div[2]/a[1]").click()
6         

2.单元测试的坑  如果想要执行一个指定的单元方法,使用unittest for TestCase环境, 

  命令行方式: python -m unittest  test_case.py  执行 其中所有的测试方法

        python -m unittest  test_case.类名.待执行方法名        执行指定的测试方法

 --------执行main()方法:需要配置环境,同时会全部执行测试方法

       

标签:进阶,driver,代码,selenium,TestCase,test,div,unittest,测试方法
From: https://www.cnblogs.com/shaitaiyang/p/16779831.html

相关文章

  • Java代码审计之实战某博客
    对某博客的代码审计在gitee上面找了一个个人博客项目,来进行实战代码审计,主要还是学习为主技术菜菜,哪里错误希望师傅们指正1、SQL注入先了解JavaWeb中的数据传输流程g......
  • PHP使用华科云HTTP代码
    //要访问的目标页面$targetUrl="http://ip.hahado.cn/ip";//$targetUrl="http://ip.hahado.cn/switch-ip";//$targetUrl="http://ip.hahado.cn/current-......
  • C Sharp中使用HTTP的代码
    在云中,可以加入HTTP来提高抓取成功概率,以华科HTTP为例:HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create("​​http://ip.hahado.cn/ip​​​");WebProxymyProx......
  • WebAssembly01--c代码调用js
    编译选项emcctest.c--js-librarypkg.js-otest.jspkg.jsmergeInto(LibraryManager.library,{js_add:function(a,b){console.log("js_add");......
  • <三>从编译器角度理解C++代码编译和链接原理
    1代码点击查看代码**sum.cpp**intgdata=10;intsum(inta,intb){returna+b;}**main.cpp**externintgdata;intsum(int,int);intdata=20;intmain......
  • 在信息安全系统实验箱中部署、运行代码
    目录在信息安全系统实验箱中部署、运行代码交叉编译环境的搭建准备实验箱编写代码配置NetworkFileSystem(NFS)——网络文件系统win7虚拟机连接实验箱传输并运行代码过程......
  • Entity Framework教程-代码优先开发方式详解(Code First Development)
    更新记录转载请注明出处:2022年10月12日发布。2022年10月9日从笔记迁移到博客。EFCore代码优先开发方式详解(CodeFirstDevelopment)说明记得先安装EF包,再使用记......
  • 代码随想录训练营|Day 22|235,701,450
    235.LowestCommonAncestorofaBinarySearchTreeGivenabinarysearchtree(BST),findthelowestcommonancestor(LCA)nodeoftwogivennodesintheBST.......
  • Ceph使用---Crush Map进阶
    一、CephCrushMap介绍ceph集群中由mon服务器维护的的五种运行图:Monitormap#监视器运行图OSDmap#OSD运行图PGmap#PG运行图Crushmap#(Controllersrepl......
  • git提交代码详解
    刚开始做项目的时候,git怎么提交代码?一般情况是我们现在github或者gitee上新建一个仓库,然后将建好的仓库clone到本地,最后在clone下来的代码的基础上撸代码。撸完代码之后,添......