I am trying to automate instagram following. I go to a profile and click on the followers link. It opens a modal type div and there are all the followers. It first finds all the follow buttons present in the DOM and clickson them. After that it scrolls down and finds more follow buttons in the DOM and clicks on them. But after scrolling 2-3 times the automation stops and gives this error.
!Scrollable Div Image: https://imgur.com/6s3nGJs
Attaching the code below for collecting the follow buttons and clicking on them:
element(by.xpath("//div[@role='dialog']")).element(by.tagName("ul")).all(by.buttonText("Follow")).then(links => {
console.log("Links Length" + links.length);
if (links.length == 0) {
this.ScrollDown();
}
else {
for (let i = 0; i < links.length; i++) {
if (i >= links.length - 2) {
console.log("Scrolling Down");
browser.actions().sendKeys(protractor.Key.PAGE_DOWN).perform().then(function(){
console.log("Scrolled");
browser.sleep(3000);
});
break;
}
else {
browser.actions().mouseMove(links[i]).click().perform().then(function () {
console.log("Clicked on link " + (i + 1));
browser.sleep(3000);
});
}
}
this.followProfiles();
}
});
ScrollDown:
console.log("Scrolling Down");
browser.wait(browser.actions().sendKeys(protractor.Key.PAGE_DOWN).perform().then(function () {
console.log("Scrolled down");
}), 90000);
browser.sleep(5000);
this.followProfiles();