在这个网址上,我需要用字符串“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]'));
});
});发布于 2020-11-04 16:42:03
您可以使用each()遍历所有的td并搜索该元素。类似于:
cy.get('[ng-repeat="column in columns"]').each(($ele, i) => {
if ($ele.text === 'xyz') {
cy.log('Search Successful for ' + ($ele.text))
}
})https://stackoverflow.com/questions/64675499
复制相似问题