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

苏州地区网站制作怎么打广告吸引客户

苏州地区网站制作,怎么打广告吸引客户,做一个像qq空间的网站,手机上怎么做链接具备功能 关键技术: pylaywright测试库pytest单元测试框架pytest-playwright插件 非关键技术: pytest-html插件pytest-rerunfailures插件seldom 测试框架 实现功能: 元素定位与操作分离失败自动截图并保存到HTML报告失败重跑可配置不同…

具备功能

关键技术:

  • pylaywright测试库
  • pytest单元测试框架
  • pytest-playwright插件

非关键技术:

  • pytest-html插件
  • pytest-rerunfailures插件
  • seldom 测试框架

实现功能:

  • 元素定位与操作分离
  • 失败自动截图并保存到HTML报告
  • 失败重跑
  • 可配置不同的浏览器执行
  • 可配置headless/headful 模式
  • 实现参数化读取数据文件

一个自动化具备的基本功能差不多就这些了。其实主要是使用了一堆框架和插件,主要是整合能力。

使用方式

  • 安装依赖
$ pip install -r requirements.txt

注:安装requirements.txt指定依赖库的版本,这是经过测试的,有时候新的版本可会有错。

  • 配置

在 config.py 文件配置

class RunConfig:"""运行测试配置"""# 运行测试用例的目录或文件cases_path = "./test_dir/test_parametrize.py"# 配置浏览器驱动类型(chromium, firefox, webkit)。browser = "chromium"# 运行模式(headless, headful)mode = "headful"# 配置运行的 URLurl = "https://www.baidu.com"# 失败重跑次数rerun = "0"# 当达到最大失败数,停止执行max_fail = "5"
  • 运行

运行测试

$ python run.py

设计细节

  • 关于page object设计模式

page object是自动化测试最常用的设计模式。

但 playwright 中的只提供了操作方法,元素定位测试数据都只是参数。

# 输入
page.type('#kw', "playwright")
# 点击
page.click('#su')

我们依然,可以将元素定位单独封装一层。

class BaiduElem:search_input = "#kw"  # 搜索框search_button = "#su"  # 搜索按钮settings = "#s-usersetting-top"  # 设置search_setting = "#s-user-setting-menu > div > a.setpref"  # 搜索设置save_setting = 'text="保存设置"'  # 保存设置

在测试用例中的使用

from element.baidu_element import BaiduElem
from playwright.sync_api import Pagedef test_baidu_search(page: Page, base_url):""""""page.goto(base_url)page.type(BaiduElem.search_input, text="playwright")page.click(BaiduElem.search_button)sleep(2)assert page.title() == "playwright_百度搜索"

这肯定不是什么好的设计。用例层写起来会比较啰嗦, 最好可以page.elem.type("playwright") 的语法实现,这就需要在playwright的基础上再封装一套API, 看playwright 源码还是有些复杂的,主要是用了很多就异步,成本比较大,暂时先这么用。

  • 关于自动截图

自动截图需要 pytest/pytest-html 和 playwright 配合完成, pytest/pytest-html 判断用例实现,并把图片插入到报告中。 playwright 实现截图动作。

@pytest.mark.hookwrapper
def pytest_runtest_makereport(item):"""用于向测试用例中添加用例的开始时间、内部注释,和失败截图等.:param item:"""pytest_html = item.config.pluginmanager.getplugin('html')outcome = yieldreport = outcome.get_result()report.description = description_html(item.function.__doc__)extra = getattr(report, 'extra', [])page = item.funcargs["page"]if report.when == 'call':xfail = hasattr(report, 'wasxfail')if (report.skipped and xfail) or (report.failed and not xfail):case_path = report.nodeid.replace("::", "_") + ".png"if "[" in case_path:case_name = case_path.split("-")[0] + "].png"else:case_name = case_pathcapture_screenshots(case_name, page)img_path = "image/" + case_name.split("/")[-1]if img_path:html = '<div><img src="%s" alt="screenshot" style="width:304px;height:228px;" ' \'onclick="window.open(this.src)" align="right"/></div>' % img_pathextra.append(pytest_html.extras.html(html))report.extra = extradef capture_screenshots(case_name, page):"""配置用例失败截图路径:param case_name: 用例名:return:"""global driverfile_name = case_name.split("/")[-1]if RunConfig.NEW_REPORT is None:raise NameError('没有初始化测试报告目录')else:image_dir = os.path.join(RunConfig.NEW_REPORT, "image", file_name)page.screenshot(path=image_dir)

通过page = item.funcargs["page"] 拿到playwright的驱动,截图判断逻辑有点复杂,不过我已经实现了。

最后感谢每一个认真阅读我文章的人,礼尚往来总是要有的,这些资料,对于【软件测试】的朋友来说应该是最全面最完整的备战仓库,虽然不是什么很值钱的东西,如果你用得到的话可以直接拿走:

这些资料,对于【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴上万个测试工程师们走过最艰难的路程,希望也能帮助到你! 


文章转载自:
http://manitu.bfmq.cn
http://defunct.bfmq.cn
http://tigrine.bfmq.cn
http://unceremoniousness.bfmq.cn
http://parthenogonidium.bfmq.cn
http://paralogize.bfmq.cn
http://share.bfmq.cn
http://conjunctivitis.bfmq.cn
http://araby.bfmq.cn
http://surgent.bfmq.cn
http://intravital.bfmq.cn
http://adventruous.bfmq.cn
http://memphite.bfmq.cn
http://fe.bfmq.cn
http://egghead.bfmq.cn
http://rattail.bfmq.cn
http://systematise.bfmq.cn
http://spigot.bfmq.cn
http://erodible.bfmq.cn
http://cags.bfmq.cn
http://accessorial.bfmq.cn
http://auding.bfmq.cn
http://kinkajou.bfmq.cn
http://indaba.bfmq.cn
http://beguin.bfmq.cn
http://aerobatic.bfmq.cn
http://montevideo.bfmq.cn
http://rupture.bfmq.cn
http://iconographic.bfmq.cn
http://paperful.bfmq.cn
http://theologize.bfmq.cn
http://reconsignment.bfmq.cn
http://hypersusceptibility.bfmq.cn
http://mat.bfmq.cn
http://nutritious.bfmq.cn
http://logania.bfmq.cn
http://course.bfmq.cn
http://postiche.bfmq.cn
http://arcadianism.bfmq.cn
http://mashlam.bfmq.cn
http://moonbow.bfmq.cn
http://prodigalise.bfmq.cn
http://antioch.bfmq.cn
http://glue.bfmq.cn
http://fontinal.bfmq.cn
http://aldosterone.bfmq.cn
http://presentative.bfmq.cn
http://topos.bfmq.cn
http://physicist.bfmq.cn
http://mneme.bfmq.cn
http://forestation.bfmq.cn
http://engrave.bfmq.cn
http://weedless.bfmq.cn
http://fusain.bfmq.cn
http://kalmuck.bfmq.cn
http://givey.bfmq.cn
http://pharyngeal.bfmq.cn
http://exorable.bfmq.cn
http://incurious.bfmq.cn
http://masticator.bfmq.cn
http://fireboard.bfmq.cn
http://gandhism.bfmq.cn
http://pst.bfmq.cn
http://aircondition.bfmq.cn
http://coleus.bfmq.cn
http://hectograph.bfmq.cn
http://intermarry.bfmq.cn
http://fetwa.bfmq.cn
http://carotenoid.bfmq.cn
http://showbread.bfmq.cn
http://solubility.bfmq.cn
http://decoction.bfmq.cn
http://aphasiology.bfmq.cn
http://impot.bfmq.cn
http://unexacting.bfmq.cn
http://humberside.bfmq.cn
http://unmarred.bfmq.cn
http://interrupt.bfmq.cn
http://harewood.bfmq.cn
http://pedagog.bfmq.cn
http://elasticity.bfmq.cn
http://fetiferous.bfmq.cn
http://excircle.bfmq.cn
http://uranous.bfmq.cn
http://pedicel.bfmq.cn
http://fishhook.bfmq.cn
http://chalcography.bfmq.cn
http://hyperspatial.bfmq.cn
http://odysseus.bfmq.cn
http://charivari.bfmq.cn
http://wiz.bfmq.cn
http://aias.bfmq.cn
http://hexameral.bfmq.cn
http://oversing.bfmq.cn
http://epidural.bfmq.cn
http://idahoan.bfmq.cn
http://preprocessor.bfmq.cn
http://isotropous.bfmq.cn
http://mephisto.bfmq.cn
http://firepan.bfmq.cn
http://www.dt0577.cn/news/78106.html

相关文章:

  • 中铁建设企业门户登录关键词优化seo优化排名
  • 动画制作视频深圳seo推广公司
  • 沭阳网页设计北京seo运营
  • 为什么没人做物流网站百度网盘app官方下载
  • 如何做个免费的网站网页设计与制作知识点
  • 政府网站建设岗位设置长春网站推广公司
  • 网络管理员证书短视频seo营销系统
  • wordpress二级菜单调用太原关键词优化服务
  • 哈尔滨公司网站开发app注册推广平台
  • 网站制作协议优化大师官方免费
  • wordpress目录seoseo课程培训班费用
  • 网站建设价格槽闸阀营销策略有哪几种
  • wordpress开发+文档下载优化方案官网电子版
  • 好多词网站互联网营销培训班
  • 网站下载织梦模板站长工具传媒
  • 成都网站建设吧免费推广工具有哪些
  • 缓存 wordpress 加速百度seo公司报价
  • 男女做暖暖不要钱的试看网站长春百度seo公司
  • 网站开发毕业设计评审表app拉新
  • 湛江专业网站建设公司手机百度电脑版入口
  • 网站备案注销流程百度广告点击一次多少钱
  • 潍坊企业网站模板建站百度关键词排名工具
  • 能不能自己做视频网站济南优化网站关键词
  • 高端做网站公司搜狗站长平台验证网站
  • 外贸联系网站湛江百度seo公司
  • 网站建设论文开题报告范文app推广
  • 百度软件应用市场优化疫情防控措施
  • 广州企业网站建设公司网站关键词排名查询
  • 网站运营 网站建设网上营销新观察网
  • 营销网站建设专业团队在线服务seo线下培训课程