有没有办法刮掉或删除 element.all 数组返回的随机值或少数值?
我试图自动化的场景是检查“HTML”这个词是否应该出现在从数组列表返回的每一行中。
我使用 w3Schools 作为虚拟测试网站来试用我的场景,下面是由于断言而失败的代码。
describe('Searching for word HTML', function() {
var array=[];
var counter=0;
it('Beginning of the test', function() {
browser.ignoreSynchronization = true;
browser.get('https://www.w3schools.com/html/default.asp');
browser.sleep(5000).then(function(){});
var lines = element.all(by.css('#leftmenuinnerinner>a'));
lines.count().then(function(counting){
console.log("There are total "+counting+" links");
counter=counter+counting;
return counting;
})
lines.getText().then(function(text){
console.log("Values:::: "+text);
for(var k=0;k<text.length;k++){
expect(text[k]).toContain('HTML');
}
})
})
})
我知道我可以使用 xpath 值并仅遍历 76 个值的循环,但我正在尝试通过 css 选择器的方法,我需要严格获取整个值列表,所以有没有办法可以修剪或刮掉值“HTTP 消息”、“HTTP 方法”、“PX 到 EM 转换器”和“键盘快捷方式”通过我返回的数组中的代码动态地传递,以便我的断言通过?