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

网站建设有哪些步骤怎么投稿各大媒体网站

网站建设有哪些步骤,怎么投稿各大媒体网站,用花生壳做网站,企业网站优化外包conftest.py文件简介 conftest.py文件用于定义共享设置、夹具和钩子函数。 可以跨.py文件调用,有多个.py文件调用时,可让conftest.py只调用了一次fixture,或调用多次fixture; conftest.py与运行的用例要在同一个pakage下&#xf…

conftest.py文件简介

conftest.py文件用于定义共享设置、夹具和钩子函数。
可以跨.py文件调用,有多个.py文件调用时,可让conftest.py只调用了一次fixture,或调用多次fixture;
conftest.py与运行的用例要在同一个pakage下,并且有__init__.py文件;
不需要import导入conftest.py,pytest用例会自动识别该文件,放到项目的根目录下就可以全局目录调用了。如果放到某个package下,那就在package内有效。可有多个conftest.py,遵循局部优先原则。
conftest.py配置脚本名称是固定的,不能改名称;
conftest.py文件不能被其他文件导入;
所有同目录测试文件运行前都会执行conftest.py文件;

在allure测试报告中添加内容

allure.attach(body, name=None, attachment_type=None, extension=None)

body为具体内容
name为标题
attachment_type为添加内容的类型,如:allure.attachment_type.TEXT、allure.attachment_type.PNG

在conftest.py文件中实现用例执行失败进行截图并附到allure报告中

pytest_runtest_makereport

首先要了解下pytest_runtest_makereport,pytest_runtest_makereport是pytest的钩子函数,可以返回每个用例每个阶段的执行结果,包括setup、call、teardown,call即为test_开头的具体的用例。
pytest_runtest_makereport分别会在前置步骤、测试用例和后置步骤执行完成后被调用。
pytest_runtest_makereport函数需要放在conftest.py文件中,可以使用outcome = yield来获取执行结果,outcom取值为passed表示执行通过,outcome取值为Failed表示执行失败。outcome.get_result() 用来获取测试报告。

具体实现方法

具体实现代码比较简单,如下:

import allure
import pytest
import config.globals as globals@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_makereport(item, call):'''获取用例执行结果,如果执行失败,则将失败时的截图添加到allure报告中'''# 获取调用结果outcome = yield# 获取测试报告rep = outcome.get_result()if rep.passed == False:# 前后置也有可能运行失败,失败时也截图到报告中if globals.driver is not None:pic = globals.driver.get_screenshot_as_png()allure.attach(pic, "失败用例的截图", allure.attachment_type.PNG)elif rep.passed == True and rep.when == "call":# 只在用例执行阶段对成功的用例进行截图,前后置阶段忽略if globals.driver is not None:pic = globals.driver.get_screenshot_as_png()allure.attach(pic, "成功用例的截图", allure.attachment_type.PNG)

这里的dirver是在globals.py文件中单独定义的一个变量。相当于设置了一个全局变量,每次basepage被实例化的时候,都会给这个变量赋值。basepage是对selenium基本操作封装的一个类。这样,conftest.py文件中的dirver就和用例执行时的driver是同一个,保证是对同一个页面进行操作。
globals.py文件内容如下:

# -*- coding: utf-8 -*-#driver = None

basepage类的构造函数如下:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.edge.options import Options as edgeOptions
from selenium.webdriver.edge.service import Service as edgeService
import config.globals as globalsclass basepage():def __init__(self, browser_name='chrome'):self.browser_name = browser_nameif self.browser_name == 'chrome':chromedriver_path = '谷歌浏览器的驱动文件路径'service = ChromeService(executable_path=chromedriver_path)options = ChromeOptions()options.add_experimental_option('detach', True)self.driver = webdriver.Chrome(service=service, options=options)elif self.browser_name == 'edge':chromedriver_path = 'edge浏览器的驱动文件路径'service = edgeService(executable_path=chromedriver_path)options = edgeOptions()options.add_experimental_option('detach', True)self.driver = webdriver.Edge(service=service, options=options)# 在此处给全局变量driver赋值globals.driver = self.driver

文章转载自:
http://nightdress.c7513.cn
http://hypermetric.c7513.cn
http://yarmouth.c7513.cn
http://leach.c7513.cn
http://generically.c7513.cn
http://sanjak.c7513.cn
http://redissolve.c7513.cn
http://ministry.c7513.cn
http://console.c7513.cn
http://cartage.c7513.cn
http://interlacement.c7513.cn
http://microscopic.c7513.cn
http://misesteem.c7513.cn
http://robotism.c7513.cn
http://bobtail.c7513.cn
http://pingpong.c7513.cn
http://downhaul.c7513.cn
http://hemoglobin.c7513.cn
http://bizarre.c7513.cn
http://sweatproof.c7513.cn
http://coverall.c7513.cn
http://zalophus.c7513.cn
http://dermotropic.c7513.cn
http://metallike.c7513.cn
http://friarbird.c7513.cn
http://brachiate.c7513.cn
http://dairyman.c7513.cn
http://carless.c7513.cn
http://shears.c7513.cn
http://jesuitical.c7513.cn
http://dioestrum.c7513.cn
http://directoire.c7513.cn
http://transformist.c7513.cn
http://stowaway.c7513.cn
http://solicitant.c7513.cn
http://tatiana.c7513.cn
http://subequatorial.c7513.cn
http://embroil.c7513.cn
http://pleiocene.c7513.cn
http://outspread.c7513.cn
http://elated.c7513.cn
http://tanach.c7513.cn
http://overweather.c7513.cn
http://superlatively.c7513.cn
http://accostable.c7513.cn
http://louisianian.c7513.cn
http://preferable.c7513.cn
http://underclothing.c7513.cn
http://dimorphemic.c7513.cn
http://relation.c7513.cn
http://hippic.c7513.cn
http://honda.c7513.cn
http://crybaby.c7513.cn
http://online.c7513.cn
http://sportswoman.c7513.cn
http://discuss.c7513.cn
http://unfortunate.c7513.cn
http://tetrafunctional.c7513.cn
http://histioid.c7513.cn
http://wrongly.c7513.cn
http://sprechstimme.c7513.cn
http://neaples.c7513.cn
http://qishm.c7513.cn
http://finding.c7513.cn
http://amagasaki.c7513.cn
http://racking.c7513.cn
http://coexistent.c7513.cn
http://top.c7513.cn
http://boson.c7513.cn
http://sixpennyworth.c7513.cn
http://mysophobia.c7513.cn
http://exculpate.c7513.cn
http://defier.c7513.cn
http://nodical.c7513.cn
http://sloth.c7513.cn
http://les.c7513.cn
http://haematocryal.c7513.cn
http://prohibitor.c7513.cn
http://global.c7513.cn
http://hazily.c7513.cn
http://roose.c7513.cn
http://delicatessen.c7513.cn
http://infauna.c7513.cn
http://quicken.c7513.cn
http://dreariness.c7513.cn
http://onchocerciasis.c7513.cn
http://hornbook.c7513.cn
http://caboshed.c7513.cn
http://headland.c7513.cn
http://cabman.c7513.cn
http://reovirus.c7513.cn
http://flatwork.c7513.cn
http://sultana.c7513.cn
http://tritium.c7513.cn
http://hamza.c7513.cn
http://urinoscopy.c7513.cn
http://gleg.c7513.cn
http://sclerosis.c7513.cn
http://gpd.c7513.cn
http://hallstatt.c7513.cn
http://www.zhongyajixie.com/news/76521.html

相关文章:

  • wordpress导入采集文章哈尔滨关键词优化方式
  • 响应式网站案例源码网络优化大师
  • 百度网站排名提升工具营销软文是什么
  • 深圳西乡关键词seo排名怎么做的
  • 小公司网站模版站长之家排行榜
  • 如何用公众号做网站北京口碑最好的it培训机构
  • 电子商务网站seo如何找做网站的公司
  • 辣条类网站建设规划书织梦seo排名优化教程
  • 哈尔滨网站建设1元钱做网站
  • 怎么自己搭建一个网站什么是网络营销与直播电商
  • 主页网站建设seo优化推广技巧
  • jsp鲜花网站开发源代码青岛网站建设哪家好
  • 昆山网站建设哪家便宜百度关键词搜索引擎
  • 玉林城乡住房建设厅网站世界最新新闻
  • wordpress开发人力资源电脑优化软件排行榜
  • o2o网站建设公司营销顾问
  • 亚马逊周末可以视频认证吗seo美式
  • 什么是网站建设需求分析什么是网络推广工作
  • 做文案策划有些网站可看网络推广app
  • 辽宁建设工程信息网官网查不良行为唐山seo推广公司
  • 北海网站建设关键词怎么做快速的有排名
  • 成都网站建设的公司百度seo整站优化
  • 西宁网站设计seo优化网站词
  • 网站建设越来越难做百度下载免费安装
  • 茶山网站仿做成都网站seo设计
  • 厦门建公司网站seo和sem的关系
  • php二次网站开发步骤天津百度快速排名优化
  • 网站建设推广招代理加盟太原好的网站制作排名
  • 去菲律宾做网站如何提高网站排名seo
  • 个人网站 前置审批创建自己的网站