javascript - 用字符串“abc”搜索页面并在登录cypress中打印搜索结果
问题描述
在此 URL 上,我需要使用字符串“abc”搜索页面并在登录 cypress 时打印出搜索结果,有人可以建议怎么做吗? http://www.way2automation.com/angularjs-protractor/webtables/
import {BasePage} from '../page-objects/base-page';
import {HomePage} from '../page-objects/home-page';
describe('Search text and print in Log', () => {
const basePage = new BasePage();
const homePage = new HomePage();
it('Launch Way2', () => {
basePage.navigate();
});
it('Search the page with string “xyz” and print out the search result in log', () => {
const log = Cypress.log(homePage.serachTest());
const l = Cypress.log(cy.get('body'));
const t = Cypress.log(cy.get('[ng-controller=mainCtrl]'));
});
});
解决方案
您可以使用each()并遍历所有td
并搜索元素。就像是:
cy.get('[ng-repeat="column in columns"]').each(($ele, i) => {
if ($ele.text === 'xyz') {
cy.log('Search Successful for ' + ($ele.text))
}
})
推荐阅读
- openedge - 如何创建将八进制转换为二进制?
- dependencies - 如何解决 jasper 1.8.0 对 Grails 4 的依赖?
- hdmi - hdmi usb dongle macrosilicon 2109 重命名设备
- amp-html - 带有溢出元素的动态 amp-list - 隐藏在列表数据缩减中
- amazon-web-services - S3 网站下载文件而不是显示页面
- sdn - 使用 ryu 控制器在 sdn 交换机中空闲超时后的数据包输入请求
- css - Vaadin 14拖动目标类不起作用
- django-rest-framework - 如何使用json高效解析多个数据?
- python - 如何根据其他列的查找来填充数据框列?
- spring - 我正在使用 websocket 在与 Spring Boot 和 STOMP 客户端与 js 的聊天中发送图像