摘要:
"""fixtures的概念前面已经有过简单的介绍,可以形象地把它看作是夹心饼干外层的两片饼干,这两片饼干就是setUp/tearDown,中间的心就是测试用例。除此之外,unittest还提供了更大范围的fixtures,例如对于测试类和模块的fixtures。"""import unittest 阅读全文
posted @ 2020-01-18 23:51
干it的小张
阅读(650)
评论(0)
推荐(0)
摘要:
from selenium import webdriver#引入keys模块from selenium.webdriver.common.keys import Keysdriver = webdriver.Chrome()driver.get("https://www.baidu.com")#输 阅读全文
posted @ 2020-01-18 23:48
干it的小张
阅读(177)
评论(0)
推荐(0)
摘要:
import unittestfrom selenium import webdriverclass BaiduTest(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() self.driver.implic 阅读全文
posted @ 2020-01-18 23:46
干it的小张
阅读(289)
评论(0)
推荐(0)
摘要:
from selenium import webdriver#引入ActionChains类:from selenium.webdriver.common.action_chains import ActionChainsdriver = webdriver.Chrome()driver.maxim 阅读全文
posted @ 2020-01-18 23:44
干it的小张
阅读(183)
评论(0)
推荐(0)
摘要:
from selenium import webdriversearch_text = ["python","中文","text"]for text in search_text: driver = webdriver.Firefox() driver.implicitly_wait(10) dri 阅读全文
posted @ 2020-01-18 23:42
干it的小张
阅读(209)
评论(0)
推荐(0)
摘要:
public.py from selenium import webdriverclass Login(): def user_login(self,driver,username,password): driver.find_element_by_id("switchAccountLogin"). 阅读全文
posted @ 2020-01-18 23:40
干it的小张
阅读(285)
评论(0)
推荐(0)
摘要:
from selenium import webdriverimport timedriver = webdriver.Chrome()driver.implicitly_wait(10)driver.get("http://www.baidu.com")#获得百度搜索窗口句柄sreach_wind 阅读全文
posted @ 2020-01-18 23:38
干it的小张
阅读(156)
评论(0)
推荐(0)
摘要:
from selenium import webdriverdriver = webdriver.Chrome()driver.maximize_window()ele = driver.get("http://www.baidu.com")#id定位输入框和百度一下:driver.find_ele 阅读全文
posted @ 2020-01-18 23:32
干it的小张
阅读(177)
评论(0)
推荐(0)
摘要:
#控制浏览器窗口大小:driver.set_window_size(480,800)#全屏:driver.maximize_window()#最小化:driver.minimize_window()#前进:driver.forward()#后退:driver.back()#刷新当前页面:driver 阅读全文
posted @ 2020-01-18 23:27
干it的小张
阅读(155)
评论(0)
推荐(0)
摘要:
from selenium import webdriverdriver = webdriver.Firefox()driver.get("http://www.youdao.com")#获得cookie信息:cookie = driver.get_cookies()# print(cookie)# 阅读全文
posted @ 2020-01-18 23:26
干it的小张
阅读(152)
评论(0)
推荐(0)
摘要:
#清除文本:clear()#模拟按键输入:send_keys(*value)#点击元素:click()#回车/提交表单:submit()#获取输入框尺寸:from selenium import webdriverdriver = webdriver.Chrome()size = driver.fi 阅读全文
posted @ 2020-01-18 23:23
干it的小张
阅读(111)
评论(0)
推荐(0)
摘要:
from selenium import webdriverdriver = webdriver.Chrome()#获取titletitle = driver.title#获取URLnow_url = driver.current_url#获取文本user = driver.find_element 阅读全文
posted @ 2020-01-18 23:22
干it的小张
阅读(212)
评论(0)
推荐(0)
摘要:
"""text 返回alert/confirm/prompt中的文字信息accept():接收现有的警告框dismiss():解散现有的警告框send_keys(keysToSend):发送文本至警告框"""from selenium import webdriverfrom selenium.we 阅读全文
posted @ 2020-01-18 23:21
干it的小张
阅读(113)
评论(0)
推荐(0)
摘要:
from selenium import webdriverfrom time import sleepdriver = webdriver.Firefox()driver.get("http://www.baidu.com")driver.set_window_size(600,600)drive 阅读全文
posted @ 2020-01-18 23:19
干it的小张
阅读(117)
评论(0)
推荐(0)
摘要:
from random import randint#生成一个1000到9999之间的随机整数verify = randint(1000,9999)print(u"生成的随机数:%d" %verify)number = input("请输入随机数:")print(number)number = in 阅读全文
posted @ 2020-01-18 23:18
干it的小张
阅读(143)
评论(0)
推荐(0)
摘要:
from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdrive 阅读全文
posted @ 2020-01-18 23:17
干it的小张
阅读(269)
评论(0)
推荐(0)
摘要:
HTMLTestRunner.py """A TestRunner for use with the Python unit testing framework. Itgenerates a HTML report to show the result at a glance.The simples 阅读全文
posted @ 2020-01-18 23:16
干it的小张
阅读(224)
评论(0)
推荐(0)
摘要:
"""在执行用例的过程中,最终用例是否执行通过,是通过判断测试得到的实际结果与预期结果是否相等决定的。unittest框架的TestCase类提供下面这些方法用于测试结果的判断。""""""方法 检查 版本assertEqual(a,b) a==bassertNotEqual(a,b) a!=bas 阅读全文
posted @ 2020-01-18 23:09
干it的小张
阅读(185)
评论(0)
推荐(0)
摘要:
calculator.py class Count: def __init__(self,a,b): self.a = int(a) self.b = int(b) #计算加法 def add(self): return self.a + self.b #计算减法 def sub(self): re 阅读全文
posted @ 2020-01-18 23:07
干it的小张
阅读(657)
评论(0)
推荐(0)
摘要:
from selenium import webdriverimport os,timedriver = webdriver.Chrome()driver.get("http://www.baidu.com")#选择页面上所有的tag name为input的元素inputs = driver.fin 阅读全文
posted @ 2020-01-18 23:05
干it的小张
阅读(224)
评论(0)
推荐(0)
摘要:
from selenium import webdriver#引入By类:from selenium.webdriver.common.by import Bydriver = webdriver.Chrome()#通过class属性定位输入框和百度一下、点表示通过class属性来定位元素:driv 阅读全文
posted @ 2020-01-18 23:04
干it的小张
阅读(223)
评论(0)
推荐(0)
摘要:
from selenium import webdriverfrom time import sleepdriver = webdriver.Firefox()driver.get("http://videojs.com")video = driver.find_element_by_xpath(" 阅读全文
posted @ 2020-01-18 23:03
干it的小张
阅读(185)
评论(0)
推荐(0)
摘要:
from selenium import webdriverimport osfp = webdriver.FirefoxProfile()#保存到指定目录:fp.set_preference("browser.download.folderList",2)#是否显示开始、True为显示、false 阅读全文
posted @ 2020-01-18 22:58
干it的小张
阅读(233)
评论(0)
推荐(0)
摘要:
"""上传文件是比较常见的Web功能之一,但WebDriver并没有提供专门用于上传的方法,如何实现上传操作关键在于上传文件的思路。一般Web页面的上传功能的操作需要单击“上传”按钮后打开本地的Window窗口,从窗口中选择本地文件进行上传。而WebDriver是无法操作Windows控件的,所以, 阅读全文
posted @ 2020-01-18 22:56
干it的小张
阅读(275)
评论(0)
推荐(0)
摘要:
"""在运行测试时,有时需要直接跳过某些测试用例,或者当用例符合某个条件时跳过测试,又或者直接将测试用例设置为失败。unittest提供了实现这些需求的装饰器。·unittest.skip(reason)无条件地跳过装饰的测试,说明跳过测试的原因。·unittest.skipIf(condition 阅读全文
posted @ 2020-01-18 22:54
干it的小张
阅读(152)
评论(0)
推荐(0)
摘要:
"""1.Test Case一个TestCase的实例就是一个测试用例。什么是测试用例呢?就是一个完整的测试流程,包括测试前准备环境的搭建(setUp)、实现测试过程的代码(run),以及测试后环境的还原(tearDown)。单元测试(unit test)的本质也就在这里,一个测试用例就是一个完整的 阅读全文
posted @ 2020-01-18 22:53
干it的小张
阅读(230)
评论(0)
推荐(0)
摘要:
"""用例的执行顺序涉及多个层级:在多个测试目录的情况下,先执行哪个目录?在多个测试文件的情况下,先执行哪个文件?在多个测试类的情况下,先执行哪个测试类?在多个测试方法(用例)的情况下,先执行哪个测试方法?"""import unittestclass TestBdd(unittest.TestCa 阅读全文
posted @ 2020-01-18 22:52
干it的小张
阅读(901)
评论(0)
推荐(0)
摘要:
calculator.py class Count: def __init__(self,a,b): self.a = int(a) self.b = int(b) #计算加法 def add(self): return self.a + self.b #计算减法 def sub(self): re 阅读全文
posted @ 2020-01-18 22:51
干it的小张
阅读(1106)
评论(0)
推荐(0)
摘要:
#导入xml的minidom模块、用来处理xml文件、from xml.dom import minidom#打开xml文档:dom = minidom.parse("info.xml")#得到文档元素对象root = dom.documentElement#节点名:print(root.nodeN 阅读全文
posted @ 2020-01-18 22:48
干it的小张
阅读(187)
评论(0)
推荐(0)
摘要:
"""read():读取整个文件。readline():读取一行数据。readlines():读取所有行的数据。"""user_file = open("user_info","r")lines = user_file.readlines()user_file.close()for line in 阅读全文
posted @ 2020-01-18 22:46
干it的小张
阅读(269)
评论(0)
推荐(0)
摘要:
import csv#读取本地csv文件date = csv.reader(open("info.csv","r"))#循环输出每一行信息for i in date: print(i) #取用户邮箱地址 print(i[1]) 阅读全文
posted @ 2020-01-18 22:36
干it的小张
阅读(147)
评论(0)
推荐(0)
摘要:
from threading import Threadfrom selenium import webdriverfrom time import ctime,sleep#测试用例def test_baidu(browser,search): print("start:%s" % ctime()) 阅读全文
posted @ 2020-01-18 22:34
干it的小张
阅读(219)
评论(0)
推荐(0)
摘要:
"""多进程multiprocessing模块的使用与多线程threading模块的用法类似。multiprocessing提供了本地和远程的并发性,有效地通过全局解释锁(Global Interceptor Lock,GIL)来使用进程(而不是线程)。由于GIL的存在,在CPU密集型的程序当中,使 阅读全文
posted @ 2020-01-18 22:32
干it的小张
阅读(140)
评论(0)
推荐(0)
摘要:
import threadingfrom time import sleep,ctime#创建线程类:class MyThread(threading.Thread): def __init__(self,func,args,name=""): threading.Thread.__init__(s 阅读全文
posted @ 2020-01-18 22:30
干it的小张
阅读(186)
评论(0)
推荐(0)
摘要:
"""multiprocessing提供了threading包中没有的IPC(进程间通信),效率上更高。应优先考虑Pipe和Queue,避免使用Lock/Event/Semaphore/Condition等同步方式(因为它们占据的不是用户进程的资源)。multiprocessing包中有Pipe类和 阅读全文
posted @ 2020-01-18 22:29
干it的小张
阅读(188)
评论(0)
推荐(0)
摘要:
from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom time import sleep#创建page类:class Page(object): """ 基础类、用于页面对象类的继承 """ log 阅读全文
posted @ 2020-01-18 22:28
干it的小张
阅读(140)
评论(0)
推荐(0)
摘要:
Python 知识补充if_name_="_main":语句说明在后面实例中我们会经常用到这个语句,在解释它之前先补充点Python知识:1.Python文件的后缓为。py。2.py文件既可以用来直接执行,就像一个小程序一样,也可以用来作为模块被导入。3.在Python中导入模块一般使用的是impo 阅读全文
posted @ 2020-01-18 22:27
干it的小张
阅读(168)
评论(0)
推荐(0)
摘要:
HTMLTestRunner.py """A TestRunner for use with the Python unit testing framework. Itgenerates a HTML report to show the result at a glance.The simples 阅读全文
posted @ 2020-01-18 22:26
干it的小张
阅读(559)
评论(0)
推荐(0)
摘要:
requests下载 pip install requests pip install -i https://doubanio.com/simple/ requests 常用的方法 响应 import requests requests.get() requests.post() r = req 阅读全文
posted @ 2020-01-18 20:58
干it的小张
阅读(289)
评论(0)
推荐(0)
摘要:
#导入多线程模块:import threadingimport osimport requests # 发送请求import timefrom bs4 import BeautifulSoup # 解析文本#导入线程池执行器和进程池执行器:from concurrent.futures import 阅读全文
posted @ 2020-01-18 20:47
干it的小张
阅读(177)
评论(0)
推荐(0)
摘要:
import osimport requests # 发送请求from bs4 import BeautifulSoup # 解析文本import reimport threadingbase_path = os.path.dirname(os.path.abspath(__file__))img_ 阅读全文
posted @ 2020-01-18 19:51
干it的小张
阅读(205)
评论(0)
推荐(0)
摘要:
#导入多线程模块:import threadingimport osimport requests # 发送请求from bs4 import BeautifulSoup # 解析文本base_path = os.path.dirname(os.path.abspath(__file__))img_ 阅读全文
posted @ 2020-01-18 19:44
干it的小张
阅读(149)
评论(0)
推荐(0)
摘要:
import osimport requests# 导入进程:from multiprocessing import Poolfrom bs4 import BeautifulSoup# 定义下载图片功能:def download_img(url, dirname=""): res = reques 阅读全文
posted @ 2020-01-18 18:28
干it的小张
阅读(148)
评论(0)
推荐(0)
摘要:
1、脚本内容:# 导入模块:import os# 分别创建文件夹:os.makedirs("py_tests/scripts")os.makedirs("py_tests/scripts/test_case_dir1")os.makedirs("py_tests/report")os.makedir 阅读全文
posted @ 2020-01-18 16:19
干it的小张
阅读(476)
评论(0)
推荐(0)
摘要:
快速入门 pytest是Python的单元测试框架,同自带的unittest框架类似,但pytest框架使用起来更简洁,效率更高。 pytest特点 入门简单易上手,文档支持较好。 支持单元测试和功能测试。 支持参数化。 可以跳过指定用例,或对某些预期失败的case标记成失败。 支持重复执行失败的c 阅读全文
posted @ 2020-01-18 15:16
干it的小张
阅读(755)
评论(0)
推荐(0)
摘要:
前言 所有的从事软件生产的都要学习软件质量,包括软件分析人员、设计人员、开发人员、测试人员、维护人员。 在软件质量管理中,我们要主要学习软件质量的定义、软件质量管理体系、软件质量模型、软件质量活动。 其中,我们要着重关注软件质量模型部分。 质量与质量管理体系 质量就是就是把客户的质量要求转化为设计参 阅读全文
posted @ 2020-01-18 14:53
干it的小张
阅读(1203)
评论(0)
推荐(0)
摘要:
1、可执行文件里面的代码:import osprint("计算1~20内的两数之和,包含1和20")def add(x,y): return int(x) + int(y)while True: try: num1 = input("请输入一个值或输入q退出:").strip() if num1.u 阅读全文
posted @ 2020-01-18 11:02
干it的小张
阅读(2411)
评论(0)
推荐(0)
摘要:
测试方法的划分 一般的,从看不看代码来划分黑、白盒测试。看代码和内部接口称为白盒测试,否则是黑盒测试方法。 而从软件是否运行的角度来划分静态和动态测试。不运行代码是静态测试,反之就是动态测试。 那么从我们人来参与的角度来看人工测试和自动化测试的。 黑、白、灰盒测试 刚才说了,我们从看不看代码来划分黑 阅读全文
posted @ 2020-01-18 08:30
干it的小张
阅读(504)
评论(0)
推荐(0)
摘要:
软件生命周期 那么,软件测试要经过一个什么样的过程呢,这就要从软件的生命周期开始说起了。软件生命周期又称为软件生存周期或系统开发生命周期,是软件的产生直到报废的生命周期。整个生命周期包括问题定义与规划、需求分析、系统设计、软件编程、软件测试、软件运维等阶段。 在周期内,我们无论是开发还是测试都依赖于 阅读全文
posted @ 2020-01-18 08:12
干it的小张
阅读(304)
评论(0)
推荐(0)
摘要:
import os#导入发送请求模块:import requests#导入解析文本模块:from bs4 import BeautifulSoup#返回上一级目录:base_path = os.path.dirname(os.path.abspath(__file__))#路径和图片文件夹拼接:im 阅读全文
posted @ 2020-01-18 00:47
干it的小张
阅读(576)
评论(0)
推荐(0)

浙公网安备 33010602011771号