【问题标题】:Alphabetical sorting by name - javascipt, cypress按名称按字母顺序排序 - javascript、cypress
【发布时间】:2021-11-25 10:32:17
【问题描述】:

我需要有关此代码的帮助

/// <reference types="cypress" />
import { get } from 'lodash';
 
 
const jsQuery = require('json-query');
const utils = require('../../../support/utils')
const roles = utils.roles;
const uri = Cypress.env('res_URL')
const AUT = roles.Admin;
const LONG_TIMEOUT = 10 * 1000;
 
describe('Alphabetical name sorting', () => {
 
    before(function () {
        //Log in 
        cy.login_Res(AUT.username, AUT.password)
    })
 
 
 
    it("sorting test", () => {
        cy.visit(`${Cypress.env('res_URL')}/testpage`);
 
        const checkAscSort = (value, limit) => {
            const recordsUiAsc = cy.get('#Cust').children().map(function(){ return this.label;});
            //const ascSorted = [];
 
            cy.get(value).then(rows => {
               const end = limit || rows.length;`enter code here`
                for (let i = 1; i < end; i++) {
                    const text = rows[i].innerText.toLowerCase();
 
                    recordsUiAsc.push(text);
                    ascSorted.push(text);
                }
                         const sortArray = recordsUiAsc.sort();
            expect(recordsUiAsc).to.equal(sortArray);
 
 
            });
        }
    });
 
}) //End of Spec

这是数组 cy.get('#Cust').children().map(function(){ return this.label;}); 返回#Cust 的所有姓名和姓氏 但是当运行 cypress 时,它并没有显示期望已运行

【问题讨论】:

    标签: javascript cypress


    【解决方案1】:

    需要更多信息。 checkAscSort 在哪里调用?该函数被定义为可验证但从未调用过。这是它的参数valuelimit的内容。 limit我猜是一个数字。

    【讨论】:

      【解决方案2】:

      当我调用 CheckAscSort 时,显示 cy.get...map() 不是函数(右边是数组),所以有问题。限制是一个数字绑定。调用函数时得到 cy.get().children(...).map 不是函数

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-06-25
        相关资源
        最近更新 更多