简体   繁体   English

使用 Selenium WebDriver 在 instagram 中查找并单击所有“关注”按钮

[英]Find and click on all “follow” buttons in instagram using Selenium WebDriver

Hello Fellow Stack Overflow members and coders,各位 Stack Overflow 成员和编码人员,您好,

I am trying to make an automation script using Selenium WebDriver on Instagram where I want to follow every member a particular account is following.我正在尝试在 Instagram 上使用 Selenium WebDriver 制作一个自动化脚本,我想在其中关注特定帐户关注的每个成员。 I am stuck at a point where after navigating to user's profile (who's follower I want to follow) when I click on "following" link a new window opens and it contains all the members this user follows (as shown in following screenshot): Window opened after clicking "following" link当我点击“关注”链接时,导航到用户的个人资料(我想关注谁的关注者)后,我陷入了困境,当我点击“关注”链接时,会打开一个新窗口,其中包含该用户关注的所有成员(如下面的屏幕截图所示):窗口点击“关注”链接后打开

Now as you can see in above window only first few followers are initially loaded and then as you keep on scrolling down the users keeps on getting loaded.现在,正如您在上面的窗口中看到的那样,最初只加载了前几个关注者,然后随着您继续向下滚动,用户不断加载。

I am completely lost here on how can I move the focus to this new jquery kind of window and keep on scrolling down until the full list is loaded and then find once full list is loaded, click on follow button for each user.我完全迷失在这里如何将焦点移到这种新的 jquery 类型的窗口并继续向下滚动,直到加载完整列表,然后找到完整列表加载后,单击每个用户的关注按钮。

Your help would be really appreciated in this regard.在这方面,您的帮助将不胜感激。

I have tried various options like moving the mouse over to the window and clicking at blank location and then using Keys.Arrow_Down multiple times, finding first Follow button and then keep on pressing down button etc but it doesn't seem to be right approach and it doesn't work.我尝试了各种选项,例如将鼠标移到窗口上并单击空白位置,然后多次使用 Keys.Arrow_Down,找到第一个跟随按钮,然后继续按下按钮等,但它似乎不是正确的方法和它不起作用。 Kindly help me solve this issue.请帮我解决这个问题。

what if you...如果你...

Using a while, get all the visible elements in a list, move using JavascriptExecutor to the last of the element in the list, and keep getting the elements(doing the same, moving to the last pos in the list) until you reach the number(this is the while condition) of following(or following-1 if he/she follows you)使用一段时间,获取列表中的所有可见元素,使用 JavascriptExecutor 移动到列表中元素的最后一个,并继续获取元素(执行相同操作,移动到列表中的最后一个位置),直到达到数字(这是while条件)跟随(或跟随-1,如果他/她跟随你)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM