用 zombie.js 检查多个 类
check multiple classes with zombie.js
使用僵尸和摩卡来测试网站的前端。
僵尸文档说:
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');
使用僵尸和摩卡来测试网站的前端。 僵尸文档说:
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');