InstaPy fails when trying to follow users. Runs perfectly without unfollow/follow implemented.

Created on 25 Oct 2017  路  10Comments  路  Source: timgrossmann/InstaPy

Whenever I set the session to follow users, the script will run, but it will only get so far before it fails and spits out an "element not visible error." If I do NOT include follow/unfollow in the session commands, the script runs beautifully without fail, every single time. I've been running this locally on my Macbook Pro as well as my AWS instance and it's the same issue. Any help would be greatly appreciated.

Here are my session commands in quickstart.py:

 if you want to run this script on a server,
 simply add nogui=True to the InstaPy() constructor

session = InstaPy(username=insta_username, password=insta_password, nogui=False)
session.login()


 set up all the settings

session.set_upper_follower_count(limit=850000)
session.set_do_comment(True, percentage=13)
session.set_do_follow(enabled=True, percentage=12, times=2)
session.unfollow_users(amount=30, onlyInstapyFollowed = True)

And here is the error:

File "/Users/reco/Desktop/InstaPy/instapy/instapy.py", line 530, in like_by_tags
    followed += follow_user(self.browser, self.follow_restrict, self.username, user_name)
  File "/Users/reco/Desktop/InstaPy/instapy/unfollow_util.py", line 175, in follow_user
    follow_button.click()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 72, in click
    self._execute(Command.CLICK_ELEMENT)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 461, in _execute
    return self._parent.execute(command, params)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
  (Session info: chrome=61.0.3163.100)
  (Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.13.0 x86_64)
bug help wanted

Most helpful comment

This issue has been resolved thanks to feedback from @converge

All 10 comments

@RomeoJuliett Could you post the lines of code leading up to line 175 in your instapy/unfollow_util.py? The version I have has follow_button.click() on lines 92 and 210, but not 175 as stated in your error message.

@ateich as soon as I get home tonight I'll be sure to get that code posted.

@ateich

Looks like our code is the same. No changes have been made. Lines 92 and 210 look the same as yours.

160
161 if unfollowNum != 0 and
162 hasSlept is False and
163 unfollowNum % 10 == 0:
164 print('sleeping for about {}min'
165 .format(int(sleep_delay/60)))
166 sleep(sleep_delay)
167 hasSlept = True
168 continue
169
170 if person not in dont_include:
171 unfollowNum += 1
172 button.click()
173
174 print('--> Ongoing Unfollow ' + str(unfollowNum) +
175 ', now unfollowing: {}'

@ateich I spoke too soon about the fix!

File "/Users/reco/Desktop/InstaPy/instapy/instapy.py", line 629, in like_by_tags user_name) File "/Users/reco/Desktop/InstaPy/instapy/unfollow_util.py", line 210, in follow_user follow_button.click() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 72, in click self._execute(Command.CLICK_ELEMENT) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 461, in _execute return self._parent.execute(command, params) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute self.error_handler.check_response(response) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotVisibleException: Message: element not visible (Session info: chrome=61.0.3163.100) (Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.13.0 x86_64)

@RomeoJuliett In unfollow_util.py try replacing follow_button.click() on line 210 with the following

browser.execute_script(
                "arguments[0].click();", follow_button)

@ateich like this?

browser.execute_script(
"arguments[0].style.visibility = 'visible'; "
"arguments[0].style.height = '10px'; "
"arguments[0].style.width = '10px'; "
"arguments[0].style.opacity = 1", follow_button)
#follow_button.click()
browser.execute_script(
"arguments[0].click();", follow_button)

@RomeoJuliett Yes, exactly like that

@ateich I'll definitely give this a shot and report back on any issues. I never had a problem unfollowing since it unfollows at the very beginning of a run. It's always when it starts to follow, but it's so random. Might follow one person then crash, might follow none then crash. Either way, maybe this fix will work!

I just sent the #824 PR to fix the #734 bug, and I think it will fix this bug too, can you test it ?

This issue has been resolved thanks to feedback from @converge

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wyvers picture wyvers  路  3Comments

CharlesCCC picture CharlesCCC  路  3Comments

v77v picture v77v  路  3Comments

converge picture converge  路  3Comments

Spyd3r0us picture Spyd3r0us  路  3Comments