当前位置: 首页 > news >正文

网站做端口是什么网站模板定制

网站做端口是什么,网站模板定制,河北省建设机械协会网站,快速的网站开发工具前言 PO模式 在UI级的自动化测试中,对象设计模式表示测试正在交互的web应用,程序用户界面中的一个区域,这个是减少了代码的重复,也就是说,如果用户界面发生了改变,只需要在一个地方修改程序就可以了。 优…

前言

PO模式

在UI级的自动化测试中,对象设计模式表示测试正在交互的web应用,程序用户界面中的一个区域,这个是减少了代码的重复,也就是说,如果用户界面发生了改变,只需要在一个地方修改程序就可以了。

优势:
创建可以跨越多个测试用例共享的代码;
减少重复代码的数量;
如果用户界面发生变更后,只需要在一个地方维护就可以了;

创建ui,在ui的工程中创建对应的包和目录。utils 最后一个包的名称

 

说明:
base:基础层,主要编写底层定位元素的类,它是一个包。
common:公共类,里面编写公共使用到的方法。
config:配置文件存储目录。
data:存储测试使用到测试数据。
page:对象层,编写具体的业务逻辑,把页面每一个操作行为单独的写一个方法或者是函数。
report:测试报告目录,主要用来存放测试报告。
test:测试层,里面主要是测试模块,也可以说是每个测试的场景的代码。
utils:工具类,存放工具,如文件处理、说明文档等。
run:运行层:整个自动化测试的运行目录。

页面对象设计模式

1、base基础层
在该层中主要编写了基础代码。在该层主要定义了类WebUI,在这个类中编写了单个元素和多个元素定位的方法。

 

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.expected_conditions import NoSuchElementException
import time as tclass WebUI(object):def __init__(self,driver):#webdriver实例化后的对象self.driver=driverdef findElement(self,*args):'''单个元素定位的方式:param args::return: 它是一个元组,需要带上具体什么方式定位元素属性以及元素属性的值'''try:return self.driver.find_element(*args)except NoSuchElementException as e:return e.args[0]def findsElement(self,*args,index):'''多个元素定位的方式:param args::param index: 被定位的目标索引值:return: 它是一个元组,需要带上具体什么方式定位元素属性以及元素属性的值'''try:return self.driver.find_elements(*args)[index]except NoSuchElementException as e:return e.args[0]

2、page对象层
在这一层的类直接继承了基础层的类,以类属性的方法指明每个操作元素属性的值,然后依据操作步骤编写对应的方法。

比如关于登录的操作:输入用户名、输入密码,点击登录,获取文本的信息操作会在实例中实现的登录操作,然后把每个登录操作封装成一个方法,这样实现登录测试用例直接调用,返回失败信息—其中形式参数会在测试层赋值

注意:获取文件信息的方法,要有return返回值否则在测试层断言时获取不到文本信息,数据属性和方法名字不要一样

from base.base import *
from selenium.webdriver.common.by import Byclass Sina(WebUI):username_loc=(By.ID,'freename')password_loc=(By.ID,'freepassword')login_loc=(By.CLASS_NAME,'loginBtn')userError_loc=(By.XPATH,'/html/body/div[3]/div/div[2]/div/div/div[4]/div[1]/div[1]/div[1]/span[1]')passError_loc=(By.XPATH,'/html/body/div[3]/div/div[2]/div/div/div[4]/div[1]/div[1]/div[1]/span[2]')def inputUserName(self,username):self.findElement(*self.username_loc).send_keys(username)def inputPassWord(self,password):self.findElement(*self.password_loc).send_keys(password)def clickLogin(self):self.findElement(*self.login_loc).click()def login(self,username,password):self.inputUserName(username=username)self.inputPassWord(password=password)self.clickLogin()def getUserError(self):return self.findElement(*self.userError_loc).textdef getPassError(self):return self.findElement(*self.passError_loc).text

3、test测试层
在这里首先需要导入对象层中的类和unittest单元测试框架,在测试类中,继承了unittest.TestCase和对象层中的类,TestCase是由于在编写自动化测试的用例中,用到的测试固件、测试断言和测试执行都是需要它中的方法,而对象层中的类包含对象层中的测试操作步骤的方法,继承后可以直接进行调用。

注意:
在编写用例的时候需要添加备注信息,明确表示该用例是测试的哪个点,验证的哪个场景;
测试模块都是以test_开头,测试方法也是以test_开头的;

from page.sina import *
import  unittest
from selenium import  webdriver
import time as t
from page.init import *class SinaTest(Init,Sina):def test_username_null(self):self.login(username='',password='12345')t.sleep(3)# 验证邮箱名为空self.assertEqual(self.getUserError(),'请输入邮箱名')t.sleep(3)def test_username_supportChinese(self):self.login(username='中国',password='12345')t.sleep(3)# 验证邮箱名不支持中文self.assertEqual(self.getUserError(),'邮箱名不支持中文')t.sleep(3)def test_username_formatError(self):self.login(username='123',password='12345')t.sleep(3)# 验证邮箱名格式不正确self.assertEqual(self.getUserError(),'您输入的邮箱名格式不正确')def test_password_null(self):self.login(username='15102903662@sina.com',password='')t.sleep(3)# 验证密码为空self.assertEqual(self.getPassError(),'请输入密码')t.sleep(3)def test_login_error(self):self.login(username='15102903662@sina.com',password='724225')t.sleep(3)# 验证用户名错误self.assertEqual(self.getUserError(),'登录名或密码错误')t.sleep(3)

4、data数据层
春初测试使用到的测试数据(主要是把数据写入json文件,yaml文件)

在data下创建json文件

5、common层
common:公共层,里面编写公共使用到的文件(处理路径—重点处理的是json文件或者yaml文件)一般时定义基础路径的

在这个层创建public.py 文件
导入os库,定义基础路径(也就是把基础路径处理为将要读取文件所在文件夹的路径,这样方便使用的时候做路径拼接)

import osdef base_dir():return os.path.dirname(os.path.dirname(__file__))# print(base_dir())

6、untils层
工具层:基本上是对data里面的(json yaml文件的读取)

在untils下创建模块:operationJson.py,设置方法readJson()来读取数据

在这个模块我们需要导入os来进行路径拼接,Json反序列化用来读取文件,还有就是导入公共层下的基础路径

import os
from common.public import base_dir
import jsondef readJson():return json.load(open(file=os.path.join(base_dir(),'data','sina.json'),encoding='utf-8'))

B6

7、config层
配置文件存储目录

8、run层
运行层,主要是运行测试用例的目录,我们可以根据测试模块来运行,也可以运行所有的模块,该层的内容也适用于所有场景(适用的前提是po设计模式的目录结构如上所示)

测试报告:

import time
# 时间
import unittest
# 加载测试模块
import os
# 处理路径
import HTMLTestRunner
# 生成测试报告必须要用的库
def getSuite():# start_dir=加载所有的测试模块来执行,pattern=通过正则的模式加载所有的模块'''获取所有执行的测试模块'''suite = unittest.TestLoader().discover(start_dir=os.path.dirname(__file__),pattern='test_*.py')return suite# 获取当前时间
def getNowtime():return time.strftime("%y-%m-%d %H_%M_%S",time.localtime(time.time()))# 执行获取的测试模块,并获取测试报告
def main():filename=os.path.join(os.path.dirname(__file__),'report',getNowtime()+"report.html")# 把测试报告写入文件中,b是以二进制的方式写入fp=open(filename,"wb")# HTMLTestRunner实例化的过程,stream是流式写入,title是测试报告的标题,description是对测试报告的描述runner=HTMLTestRunner.HTMLTestRunner(stream=fp,title="UI自动化测试报告",description="UI自动化测试报告")runner.run(getSuite())
if __name__=="__main__":main()

9、report层
主要用于存放测试报告

感谢每一个认真阅读我文章的人,礼尚往来总是要有的,虽然不是什么很值钱的东西,如果你用得到的话可以直接拿走:

 

这些资料,对于【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴上万个测试工程师们走过最艰难的路程,希望也能帮助到你!有需要的小伙伴可以点击下方小卡片领取   

 


文章转载自:
http://azalea.qwfL.cn
http://capital.qwfL.cn
http://monometallist.qwfL.cn
http://microsystem.qwfL.cn
http://nlrb.qwfL.cn
http://minimine.qwfL.cn
http://hin.qwfL.cn
http://semifascist.qwfL.cn
http://toplofty.qwfL.cn
http://coldhearted.qwfL.cn
http://orpheus.qwfL.cn
http://nudism.qwfL.cn
http://destroy.qwfL.cn
http://lindy.qwfL.cn
http://magnetometer.qwfL.cn
http://protect.qwfL.cn
http://ringling.qwfL.cn
http://histotomy.qwfL.cn
http://aob.qwfL.cn
http://coelome.qwfL.cn
http://cadi.qwfL.cn
http://raphe.qwfL.cn
http://macadam.qwfL.cn
http://saxonism.qwfL.cn
http://alu.qwfL.cn
http://outlearn.qwfL.cn
http://ectypal.qwfL.cn
http://vlaie.qwfL.cn
http://picnicker.qwfL.cn
http://entailment.qwfL.cn
http://robbery.qwfL.cn
http://deregulate.qwfL.cn
http://suitable.qwfL.cn
http://peregrinator.qwfL.cn
http://effluvial.qwfL.cn
http://astigmatism.qwfL.cn
http://prado.qwfL.cn
http://epicotyl.qwfL.cn
http://cabbage.qwfL.cn
http://panicky.qwfL.cn
http://irresponsive.qwfL.cn
http://catalina.qwfL.cn
http://ophthalmic.qwfL.cn
http://disillusionment.qwfL.cn
http://caveator.qwfL.cn
http://bailer.qwfL.cn
http://contextual.qwfL.cn
http://personality.qwfL.cn
http://jacklighter.qwfL.cn
http://unche.qwfL.cn
http://chemolysis.qwfL.cn
http://etherify.qwfL.cn
http://flocci.qwfL.cn
http://magnetoscope.qwfL.cn
http://fieldworker.qwfL.cn
http://bluebell.qwfL.cn
http://field.qwfL.cn
http://supersonics.qwfL.cn
http://disjection.qwfL.cn
http://redeem.qwfL.cn
http://scrambler.qwfL.cn
http://chyme.qwfL.cn
http://waxbill.qwfL.cn
http://despair.qwfL.cn
http://bloc.qwfL.cn
http://ingredient.qwfL.cn
http://ticker.qwfL.cn
http://elucidator.qwfL.cn
http://pamphletize.qwfL.cn
http://shearhog.qwfL.cn
http://vagi.qwfL.cn
http://siriasis.qwfL.cn
http://bearcat.qwfL.cn
http://rife.qwfL.cn
http://wisp.qwfL.cn
http://kcmg.qwfL.cn
http://paperbound.qwfL.cn
http://pudibund.qwfL.cn
http://farruca.qwfL.cn
http://acclaim.qwfL.cn
http://volsci.qwfL.cn
http://horde.qwfL.cn
http://ninth.qwfL.cn
http://urbanism.qwfL.cn
http://muggler.qwfL.cn
http://confessant.qwfL.cn
http://erythropoietin.qwfL.cn
http://hunan.qwfL.cn
http://proverbial.qwfL.cn
http://acervate.qwfL.cn
http://decretive.qwfL.cn
http://supersound.qwfL.cn
http://bannerol.qwfL.cn
http://bracing.qwfL.cn
http://implantable.qwfL.cn
http://pinko.qwfL.cn
http://chipped.qwfL.cn
http://infertile.qwfL.cn
http://fave.qwfL.cn
http://lamentably.qwfL.cn
http://www.15wanjia.com/news/75630.html

相关文章:

  • 网站 域名空间 调试灯塔seo
  • 石家庄市城乡建设学校网站长沙优化网站哪家公司好
  • 武汉做网站最牛的公司企业管理培训课程报名
  • 用照片做视频的网站百度网盘网站入口
  • 大兴58网站起名网站制作茂名网络推广
  • 公司做直销网站专业拓客公司联系方式
  • 做logo那个网站搜狗seo刷排名软件
  • 重庆哪家网站友情链接多少钱一个
  • 个人网站模板儿童网站收录情况
  • wordpress 编辑权限关键词优化技巧有哪些
  • 网站教程dw网站流量分析
  • 网站是用什么软件做的吗百度有刷排名软件
  • 平顶山网站建设公司4001688688人工服务
  • 网站开发人员介绍百度首页 百度
  • 课程网站建设的财务分析深圳网站设计公司哪家好
  • dw做网站学习解析新闻软文范例大全
  • 怎么更改网站关键词营销方案推广
  • 如何开展一个网络营销活动优化关键词步骤
  • 手机网站主页设计网站关键词快速排名技术
  • 石家庄高端网站制作百度收录量
  • 做网站沈阳音乐接单推广app平台
  • django个人博客网站开发部署源码高端建站
  • 微商城网站开发制作5118大数据平台官网
  • 口碑好的网站建设平台看网站时的关键词
  • 做网站还是微信小程序大数据营销经典案例
  • 网站建设学什么语言今日的新闻
  • 怎么查看网站有没有备案西安关键词排名提升
  • 网站建设公司企业文化网站内容如何优化
  • 前端网页设计样例济南seo网站排名优化工具
  • ip设计seo工资待遇 seo工资多少