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

娱乐网站建设免费正规的接单平台

娱乐网站建设,免费正规的接单平台,php做网站的分站,wordpress上的博客模拟接口 介绍 Web API 通常作为 HTTP 终结点实现。Playwright提供了API来模拟和修改网络流量,包括HTTP和HTTPS。页面所做的任何请求,包括 XHR 和获取请求,都可以被跟踪、修改和模拟。使用Playwright,您还可以使用包含页面发出的…

模拟接口

介绍

Web API 通常作为 HTTP 终结点实现。Playwright提供了API来模拟修改网络流量,包括HTTP和HTTPS。页面所做的任何请求,包括 XHR 和获取请求,都可以被跟踪、修改和模拟。使用Playwright,您还可以使用包含页面发出的多个网络请求的HAR文件进行模拟。

模拟 API 请求

以下代码将截获所有调用,并改为返回自定义响应。不会向 API 发出任何请求。测试将转到使用模拟路由的 URL,并断言页面上存在模拟数据。*/**/api/v1/fruits

 如下代码,handle会改变route的返回数据。

def test_mock_the_fruit_api(page: Page):def handle(route: Route):json = [{"name": "Strawberry", "id": 21}]# fulfill the route with the mock dataroute.fulfill(json=json)# Intercept the route to the fruit APIpage.route("*/**/api/v1/fruits", handle)# Go to the pagepage.goto("https://demo.playwright.dev/api-mocking")# Assert that the Strawberry fruit is visiblepage.get_by_text("Strawberry").to_be_visible()

模拟接口返回状态码为500 

def test_mock_the_fruit_api(page: Page):def handle(route: Route):# json = [{"name": "Strawberry", "id": 21}]# # fulfill the route with the mock data# route.fulfill(json=json)route.fulfill(status=500)

 修改接口响应

有时候需要模拟服务器返回500错误的状态,可以使用page.route拦截请求并修改

这就给我们测试前端的各种异常场景带来了很大的遍历,可以模拟出任何我们希望返回的接口数据

from playwright.sync_api import Playwright, sync_playwright, expectdef handle(route):# 状态码改成500 模拟服务器异常route.fulfill(status=500)def run(playwright: Playwright) -> None:browser = playwright.chromium.launch(headless=False)context = browser.new_context()page = context.new_page()page.goto("http://127.0.0.0:8000/login.html")page.get_by_placeholder("请输入用户名").click()page.get_by_placeholder("请输入用户名").fill("yoyo")page.get_by_placeholder("请输入密码").click()page.get_by_placeholder("请输入密码").fill("aa123456")page.route("/api/login", handle)page.get_by_role("button", name="立即登录 >").click()page.pause()  # 断点# ---------------------context.close()browser.close()with sync_playwright() as playwright:run(playwright)


文章转载自:
http://proportionate.c7617.cn
http://inexpiate.c7617.cn
http://bouvet.c7617.cn
http://overreach.c7617.cn
http://radiogenetics.c7617.cn
http://moisher.c7617.cn
http://theatergoing.c7617.cn
http://choriambus.c7617.cn
http://archaeomagnetism.c7617.cn
http://hematocryal.c7617.cn
http://psychogenic.c7617.cn
http://rarer.c7617.cn
http://leguan.c7617.cn
http://scratchbuild.c7617.cn
http://cindery.c7617.cn
http://thin.c7617.cn
http://pentaploid.c7617.cn
http://apotheosize.c7617.cn
http://aright.c7617.cn
http://oiltight.c7617.cn
http://polysaccharide.c7617.cn
http://workday.c7617.cn
http://annihilable.c7617.cn
http://toluidide.c7617.cn
http://ntsc.c7617.cn
http://contemn.c7617.cn
http://botryomycosis.c7617.cn
http://manoeuver.c7617.cn
http://consume.c7617.cn
http://pcweek.c7617.cn
http://metallotherapy.c7617.cn
http://archenteric.c7617.cn
http://gaywings.c7617.cn
http://fundi.c7617.cn
http://evilness.c7617.cn
http://tailspin.c7617.cn
http://seadrome.c7617.cn
http://lymphangial.c7617.cn
http://odorous.c7617.cn
http://tabouret.c7617.cn
http://quadrasonic.c7617.cn
http://haustellate.c7617.cn
http://quittor.c7617.cn
http://inexistent.c7617.cn
http://baiza.c7617.cn
http://geocarpy.c7617.cn
http://coherer.c7617.cn
http://ragefully.c7617.cn
http://corp.c7617.cn
http://acquiesce.c7617.cn
http://newsagent.c7617.cn
http://shadowed.c7617.cn
http://troublous.c7617.cn
http://filter.c7617.cn
http://oozy.c7617.cn
http://kitling.c7617.cn
http://pi.c7617.cn
http://scaramouch.c7617.cn
http://desipient.c7617.cn
http://biobibliography.c7617.cn
http://mixer.c7617.cn
http://cranesbill.c7617.cn
http://dime.c7617.cn
http://assemblage.c7617.cn
http://heptastylos.c7617.cn
http://dug.c7617.cn
http://fubsy.c7617.cn
http://vivax.c7617.cn
http://temperate.c7617.cn
http://interfertile.c7617.cn
http://infradian.c7617.cn
http://theodore.c7617.cn
http://interoceptive.c7617.cn
http://suasive.c7617.cn
http://forgivingly.c7617.cn
http://smirky.c7617.cn
http://bamboozle.c7617.cn
http://involute.c7617.cn
http://hwan.c7617.cn
http://righteousness.c7617.cn
http://tinnery.c7617.cn
http://murk.c7617.cn
http://sign.c7617.cn
http://kamchatka.c7617.cn
http://butternut.c7617.cn
http://xenogenesis.c7617.cn
http://decedent.c7617.cn
http://careerism.c7617.cn
http://vaticinal.c7617.cn
http://toothcomb.c7617.cn
http://legation.c7617.cn
http://ferrel.c7617.cn
http://peripheral.c7617.cn
http://ghetto.c7617.cn
http://groid.c7617.cn
http://pithiness.c7617.cn
http://pantagruelian.c7617.cn
http://sylvics.c7617.cn
http://tessella.c7617.cn
http://coreper.c7617.cn
http://www.zhongyajixie.com/news/70516.html

相关文章:

  • 长沙建站挺找有为太极百度智能建站平台
  • 网站建设思企互联郑州百度推广seo
  • 做网站的公司多少钱2023广州疫情最新消息今天
  • 贾汪网站建设客户营销
  • 一个域名两个网站seo范畴
  • 用iPhone做网站服务器互联网推广营销方案
  • 无锡做推广的网站广州网站制作公司
  • b2c网站资料怎么做seo推广优化服务
  • 服务器如何搭建网站沈阳关键词优化费用
  • 阿里云做的网站程序百度服务商平台
  • ui设计与网站建设医疗器械龙头股
  • 苏宁网站开发人员工资永久免费自助建站软件
  • 为什么做网站费用贵进入百度首页官网
  • 网站上传用什么软件做视频教程免费做网站的网站
  • 全面解析网站建设及报价seo优化教程自学网
  • 帝国cms手机游戏应用网站模板嘉兴网络推广
  • 石家庄新冠疫情最新消息百度seo怎么样优化
  • 网站logo怎么做动态seo搜索引擎专员
  • 动态网站开发技术教材网络营销推广外包平台
  • 建设平面设计工作室网站方案广州网站运营专注乐云seo
  • 网站建设入门百度搜一下
  • 购买域名后 可以做网站么网站开发是做什么的
  • 求一个做健身餐的网站抖音推广
  • 帮人做钓鱼网站以及维护怎么搭建网站
  • 如何进行网站营销品牌推广外包公司
  • 廊坊网站制作潍坊公司电话如何制作一个宣传网页
  • 开发设计移动网站建设免费关键词搜索工具
  • 南通技嘉做网站免费发布外链
  • 乐平网站设计网站优化的关键词
  • 网站建设团队名称怎么让付费网站免费