首页 > 解决方案 > Mocha - 如何在 it 函数中使用乘法函数

问题描述

所以我一直在试图弄清楚是否有可能做这样的事情。

it('Check for remove button', function () {
    element.all(by.className('btn btn-remove btn-outlined')).getText().then(function (text) {
        for (var i = 0; i < text.length; i++) {
            console.log(i) //Prints 0 1 2

            it('Click remove button - ' + i + '/3', function (done) {
                console.log("Hello") //Never prints
                browser.driver
                    .then(() => utils.click(detailsSpecs.getRemoveButton()))
                    .then(() => done());
                });

            it('Wait for fading button to be gone', function (done) {
                console.log("World")  //Never prints
                setTimeout(function () {
                    done();
                }, 1000);
            });
        };
    });
});

如您所见,我有一个代表问题的 it 函数(检查有多少元素),然后我在本身内部有两个it函数。哪个单击,第二个已超时,但我的问题是它不想在 for 循环中输入任何一个,但是 for 循环本身可以工作,而且似乎我无法在其中包含多个的功能。

我想知道我如何能够解决它 - 如果可以做这样的事情吗?

标签: javascriptseleniumprotractormocha.jschai

解决方案


推荐阅读