배열에서 웹 페이지의 모든 웹 링크를 취하려고합니다 & 웹 페이지에서 URL 링크의 위치가 텍스트와 일치하는 링크를 클릭하고 싶습니다. 고정되지 않았습니다. 아래 코드가 오류와 함께 실패합니다.링크를 검색 할 수 없다 & 그것을 클릭하십시오 - 각도기
실패 : 인덱스가 벗어납니다. 인덱스에있는 요소에 액세스하려고 : 15,하지만 자바 스크립트의 result_links.length 속성을 사용하려고하지만 이상하게 내가
var result_links =element.all(by.css('.entity.element.a'));
for (var i=0;i<22;i++){
result_links.get(i).getText().then(function(text){
console.log("The fetched links are "+text);
if (text==="Xtreme Testing -explorers 12345"){
result_links.get(i).click();
}
})
}
(CSS 선택기, .entity.element.a)에 의해 로케이터 일치하는 경우에만 0 요소가있다 그렇게 내가 정적 내가 항상 0-22
아래 코드의 출력 사이에있을 것입니다 찾고하고있는 웹 링크로 숫자 22을 할당했다 이유를 먹으 렴에 배열 번호를하지 않는 것은 :
The fetched links are Stick urls
The fetched links are Budgets 27167678
The fetched links are www.xyztyi.com
The fetched links are YT its yours
The fetched links are wwww.thytghj.com
The fetched links are Engage stick
The fetched links are Methods 156788.com
The fetched links are Stithgyuji 287878
The fetched links are Hello 679u
The fetched links are Johns 766788
The fetched links are www.gtyyuuhjhj
The fetched links are yuyuuyukuku
The fetched links are Stanfods 777686y88
The fetched links are www.xyz.com
The fetched links are Xtreme Testing -explorers 12345
위의 코드는 작동하지 않습니다. 'result_links.get (i) .getText()'를'result_links.getText()'로 변경해야합니다. –