Instagram user following automation project

假如想象 提交于 2020-06-29 03:56:26

问题


Trying to automate the process by avoiding clicking on the already requested or followed users. Instagram allows following of max. 7500 user a day. I would like to limit it to that number as well as avoid what I described in the first sentence.

My code:

List<WebElement> clickOnFollowButton = driver.findElements(By.xpath("//button[contains(text(),'Follow')]"));

 for (int i = 0; i < clickOnFollowButton.size() ; i++) {

    WebElement element = driver.findElements(By.xpath("//button[contains(text(),'Follow')]")).get(i);

    driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);

    ((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView();", element);
    element.click();

    WebElement requested = driver.findElement(By.xpath("//button[contains(text(),'Requested')]"));
    WebElement following = driver.findElement(By.xpath("//button[contains(text(),'Following')]"));
    if(element.equals(requested) || element.equals(following)){
        continue;
    }

} 

Should I create another method for the requested and following elements? Also should I use math.random to define max numbers of users in a separate method?

来源:https://stackoverflow.com/questions/62337082/instagram-user-following-automation-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!