0
votes

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();
2
Which line in the code does the error refers to? - Bilal Alam
It's not showing any line number. Just throwing this error - Sagar Samal
can you attach a screenshot of the error? - Bilal Alam

2 Answers

0
votes

you can use clicking function of js to click what you want. if element is present and have width and height (element can't be displayed) , you can use this function to click directly htlm element. click() : this function is protractor function, action of this function is same as clicking of left mouse, so element have just been present and displayed. But clicking function of js can click html element when element have just been present although element can't be displayed. clicking funtion of js :

browser.executeScript("arguments[0].click();",geocoding_switcher.getWebElement());

And, protractor usually run fast, so you should use clicking js function to click all "Follow" button in list, it make test run perfectly, don't need scroll to the element. In js, there are many scrolling function. such as :

browser.executeScript("arguments[0].scrollIntoView();", category_label.getWebElement());

-1
votes

This is because Your test is taking more time than the default timeout set for jasmine. To increase this you can add below in your protractor config file jasmineNodeOpts: { defaultTimeoutInterval: 480000 //which isbequal to 6 min // you can increase it if your test take more time than this }