typescript - 如何让赛普拉斯在页面上执行 API 脚本?
问题描述
我目前正在尝试将我的量角器代码转换为赛普拉斯代码。我的一些量角器代码涉及使网页执行 API 脚本,例如:
import { browser } from “protractor”; // this is the import I used
browser.executeScript(‘arguments[0].click()’;, this.closeButton); // this is for button clicking
browser.executeScript(‘localStorage.setItem(“example-boolean”, “false”)’); // this is for setting a value to false
这些代码行是否有赛普拉斯等价物?
解决方案
一些灵感:
import "cypress-localstorage-commands";
cy.get('#yourCloseBtnId').click(); // Clicking on the element with an ID #yourCloseBtnId
cy.setLocalStorage("example-boolean", false); // Setting an item in the local storage
推荐阅读
- git - 从 master 恢复未推送的提交
- python-3.x - 合并两个或多个列表获得具有相同长度和统计信息的唯一组合
- sql - 如何使用查询替换 BQ 中的分区?
- python - 快速傅里叶变换(FFT) - 傅里叶分辨率问题
- extract - 创建人类基因中所有可能外显子的虚拟文库制备
- python - Python:等到函数在函数内部完成
- c++ - 使用填充的本地缓冲区 OpenCL 时像素值错误
- docker-compose - 如何在 docker-compose 中重用服务定义
- reactjs - 在 React 中使用回调挂钩的 Eslint 错误
- events - Anylogic:如何计算累积和?