Ich versuche, eine Zählung der Arraylist & dann versuchen, das Vorhandensein von Schlüsselwort in den Werten des Arrays zu bestätigen. Unten ist mein Code, der Probleme hat;Kann das Vorhandensein eines Schlüsselworts in einer Arraylist nicht bestätigen
describe('My Test', function() {
it('Test starts', function() {
browser.ignoreSynchronization = true;
browser.get('https://www.w3schools.com/angular/');
browser.sleep(5000).then(function(){});
var results = element.all(by.css(".sidesection>p>a"));
var results_count=results.count().then(function(counting){
console.log("There are total "+counting+" lines");
return counting;
})
results_count.then (function(count){
console.log("There are totalx "+count+" lines");
for (var iterate=1;iterate<count;iterate++){
results.get(iterate).getText().then(function(text){
console.log("The text in Relationship Type node line "+iterate+" is ---"+text);
expect(text.indexOf('Navigation')!=-1).toBeTruthy();
})
}
})
})
})
Ausgang:
There are total 19 lines
There are totalx 19 lines
The text in Relationship Type node line 19 is ---Dropdowns
The text in Relationship Type node line 19 is ---Accordions
The text in Relationship Type node line 19 is ---Convert Weights
The text in Relationship Type node line 19 is ---Animated Buttons
The text in Relationship Type node line 19 is ---Side Navigation
The text in Relationship Type node line 19 is ---Top Navigation
The text in Relationship Type node line 19 is ---JS Animations
The text in Relationship Type node line 19 is ---Modal Boxes
The text in Relationship Type node line 19 is ---Progress Bars
The text in Relationship Type node line 19 is ---Parallax
The text in Relationship Type node line 19 is ---Login Form
The text in Relationship Type node line 19 is ---HTML Includes
The text in Relationship Type node line 19 is ---Google Maps
The text in Relationship Type node line 19 is ---Loaders
The text in Relationship Type node line 19 is ---Tooltips
The text in Relationship Type node line 19 is ---Slideshow
The text in Relationship Type node line 19 is ---Filter List
The text in Relationship Type node line 19 is ---Sort List
[31mF[0m
Failures:
1) My Test Test starts
Message:
[31m Expected false to be truthy.
I 2 Abfragen hier mit bin, an dem ich stecke:
1.) Warum ich bin immer die Nummer 19 in der ganzen Liste von Werten fest einprogrammiert, Ich möchte die Anzahl der Ausgänge iterativ wie 1,2,3,4 ... so
2.) Warum ist meine expect-Anweisung fehlgeschlagen, obwohl das Schlüsselwort in einigen der Array-Werte vorhanden ist.
Könnte jemand mich im Verständnis korrigieren & bekommen die oben genannten 2 Probleme gelöst?