gpt4 book ai didi

javascript - 使用 zombie.js 检查多个类

转载 作者:行者123 更新时间:2023-11-28 20:22:57 26 4
gpt4 key购买 nike

使用 zombie 和 mocha 来测试网站的前端。 zombie 文档说:

assert.className(selection, className, message): Asserts that selected element(s) has that and only that class name. May also be space-separated list of class names.

测试以下代码会失败:

it('Check if section class item company_bnr ', function(done){
browser.visit(url+'/aboutus', function () {
browser.assert.className('section','company_bnr item');
done();
});
});

如下:

About Us Page
1) Check if section class item company_bnr




0 passing (2s)
1 failing

1) About Us Page Check if section class item company_bnr :
Uncaught AssertionError: Expected element "section" to have class "company_bnr item", found "item"
+ expected - actual

-item
+company_bnr item

如果我将测试代码设为:

it('Check if section class item company_bnr ', function(done){
browser.visit(url+'/aboutus', function () {
browser.assert.className('section','item');
done();
});
});

我得到以下输出:

About Us Page
1) Check if section class item company_bnr




0 passing (2s)
1 failing

1) About Us Page Check if section class item company_bnr :
Uncaught AssertionError: Expected element "section" to have class "item", found "company_bnr item"
+ expected - actual

-company_bnr item
+item

最佳答案

出现的问题是 Zombie assert 对所有标签进行迭代并在遇到不匹配时停止并报告它。给出标签的绝对路径,如:

browser.assert.attribute('div section header div div span a','href','https://www.website.com');

关于javascript - 使用 zombie.js 检查多个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35203726/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com