问题
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