如何解决使用字符串“ abc”搜索页面,并在赛普拉斯登录日志中打印搜索结果
在该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))
}
})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。