InstaPy crashes in the middle of a session: "element not visible"

Created on 29 Sep 2017  ·  14Comments  ·  Source: timgrossmann/InstaPy

Hi,
First of all, thanks for developing this awesome project, loving it!
However, I'm having some issues with the script crashing in the middle of a session. I'm currently liking 5 tags, 50 images per tag. Sometimes it runs fine through all 250, sometimes it crashes seemingly randomly in the middle of the session. My last three runs I got: finished all 250, crashed after 234, crashed after 38.
Checked the logs and this is what it said for the last two crashes:
[38/50] Image from: b'vindur_hao' Number of Followers: 861 Link: b'https://www.instagram.com/p/BZmx91PjbqN/?tagged=kiteboarding' Description: b"Vindur Hao stickers are free until they're not! Follow @vindur_hao and then follow the link in bio. Fill out the form and start checking your mail for an envelope from Vindur Hao \xf0\x9f\x91\x8a\xf0\x9f\x8f\xbd\xe2\x9c\x8c\xf0\x9f\x8f\xbc #livevh Thanks to Vindur Hao flag bearer @royapit for the awesome photo!\n\n#travel #explore #hike #adventure #wanderlust #pnw #oregon #kitesurfing #kiteboarding #surf #surfing #surfer #surfboard #search #trek #climb #hike #beach #backpacker #climber #mountain #aviator #flytothelineup #fly #beach #free #stickers #freestickers\n@haloshea Thanks brother \xf0\x9f\xa4\x99\xf0\x9f\x8f\xbe\n@lifeof_sebi Thanks \xf0\x9f\x99\x8f\xf0\x9f\x8f\xbc" --> Image Liked! --> Not commented Traceback (most recent call last): File "./bot.py", line 19, in <module> session.like_by_tags(['kiteboarding', 'kitesurf', 'kiteboard', 'kitesurfing', 'extremesports'], amount=50) File "/home/ubuntu/InstaPy/instapy/instapy.py", line 531, in like_by_tags followed += follow_user(self.browser, self.follow_restrict, self.username, user_name) File "/home/ubuntu/InstaPy/instapy/unfollow_util.py", line 175, in follow_user follow_button.click() File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 72, in click self._execute(Command.CLICK_ELEMENT) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 461, in _execute return self._parent.execute(command, params) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.5/dist-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.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-1035-aws x86_64)

and

[26/50] Image from: b'redikusa' Number of Followers: 857 Link: b'https://www.instagram.com/p/BZmtyGQBN9I/?tagged=extremesports' Description: b'Talk about a crazy perspective \xf0\x9f\xa4\x99\n\xe2\x96\xaa\xef\xb8\x8fcomment your thoughts \xf0\x9f\x92\xad\n\xe2\x96\xaa\xef\xb8\x8ftag your friends below\xf0\x9f\x91\x87\n\xf0\x9f\x91\x89Follow @redikusa \xf0\x9f\x91\x88\n\xf0\x9f\x93\xb7: @tof_henry\n#redikco \xf0\x9f\xa4\x99\n.\n.\n.\n#extreme #believe #action #snowboard #snow #ocean #surf #ski #bmx #climbing #extremesports #diving #scuba #actionsports #sharks #motocross #enduro #skydiving #skateboarding #competition #life #live #beyond #redik #shred #ridiculous #gnarly #travel #adventure' --> Image Liked! --> Not commented Traceback (most recent call last): File "./bot.py", line 19, in <module> session.like_by_tags(['kiteboarding', 'kitesurf', 'kiteboard', 'kitesurfing', 'extremesports'], amount=50) File "/home/ubuntu/InstaPy/instapy/instapy.py", line 531, in like_by_tags followed += follow_user(self.browser, self.follow_restrict, self.username, user_name) File "/home/ubuntu/InstaPy/instapy/unfollow_util.py", line 175, in follow_user follow_button.click() File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 72, in click self._execute(Command.CLICK_ELEMENT) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 461, in _execute return self._parent.execute(command, params) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.5/dist-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.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-1035-aws x86_64)

The script has correctly liked the images, not commented and not followed. I'm not following those accounts already either.
The issue seems to be with "element not visible", I did some searching here and it seemed like other people were having the same issue, haven't been able to find a solution though. Any idea on how to fix this?
Please let me know if I can provide any more info.
Cheers!

bug help wanted

Most helpful comment

There is a temporary fix to that. You can just add a Try/Except to line 531 of Instapy.py (assuming you are using like by tags)
Replacing :

followed += follow_user(self.browser, self.follow_restrict, self.username, user_name)

by

try : 
     followed += follow_user(self.browser, self.follow_restrict, self.username, user_name)
except : 
     print('Element not visible Error')

It is just a band aid but it works for me, still trying to find out why it behave that way

All 14 comments

There is a temporary fix to that. You can just add a Try/Except to line 531 of Instapy.py (assuming you are using like by tags)
Replacing :

followed += follow_user(self.browser, self.follow_restrict, self.username, user_name)

by

try : 
     followed += follow_user(self.browser, self.follow_restrict, self.username, user_name)
except : 
     print('Element not visible Error')

It is just a band aid but it works for me, still trying to find out why it behave that way

Posting for the n00bs out there like myself:

                                 try :
                                    followed += follow_user(self.browser, self.follow_restrict, self.username, user_name)
                                 except Exception as err:
                                     print('Element not visible Error')

I think this is happening when you hit a user that wants you to request, Hmm Hmm??

Regards,

Oups sorry for the typo.
It might be?! It is hard to debug as it happens randomly

@julienschroder , @zooraw , @timgrossmann , is this fix still applicable? Just pulled ed8623b and now the code seems quite different and I can't find where to apply this. Is there still a need for a temporary fix or has it been fixed through a PR already?

@martinkrulltott I think we don't have this error anymore, #824 fixed it.

@converge, @timgrossmann, I'm running the latest version (a9c6ebd), still getting the "Message: element not visible" error from time to time. Same issue as https://github.com/timgrossmann/InstaPy/issues/629 ?

Full log:
Traceback (most recent call last):
File "./bot.py", line 20, in
session.like_by_tags(['ozonekites', 'northkiteboarding', 'kiteboarding', 'extremesports', 'kitesurf', 'watersports'], amount=40)
File "/home/ubuntu/InstaPy/instapy/instapy.py", line 652, in like_by_tags
self.blacklist)
File "/home/ubuntu/InstaPy/instapy/unfollow_util.py", line 219, in follow_user
follow_button.click()
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 72, in click
self._execute(Command.CLICK_ELEMENT)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 461, in _execute
return self._parent.execute(command, params)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-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.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-1038-aws x86_64)

Hey, this problem still exists, getting ”element not visible” still (although it seems less frequent, only happened once in the last 6 runs). Any possible work around?

hey @martinkrulltott , I think I fixed it, but need more testing, can you help ? https://github.com/timgrossmann/InstaPy/pull/991

991 fixed it, if you have this problem again, please reopen it.

@converge @timgrossmann Unfortunately the "element not visible" issue is back. My script crashed two days in a row somewhere in the middle.

File "/Users/roland/workspace/test/InstaPy/instapy/instapy.py", line 725, in like_by_tags self.logger) File "/Users/roland/workspace/test/InstaPy/instapy/unfollow_util.py", line 349, in follow_user follow_button.click() File "/Library/Python/2.7/site-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webelement.py", line 72, in click self._execute(Command.CLICK_ELEMENT) File "/Library/Python/2.7/site-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webelement.py", line 461, in _execute return self._parent.execute(command, params) File "/Library/Python/2.7/site-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 236, in execute self.error_handler.check_response(response) File "/Library/Python/2.7/site-packages/selenium-2.53.6-py2.7.egg/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=63.0.3239.84) (Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.12.6 x86_64)

@rvoets
same issue here, been happening again since the last pull

Same here:

Traceback (most recent call last): File "firefoxStartInstaPy.py", line 28, in <module> .like_by_tags(['dog', 'cat'], amount=10)\ File "/home/pi/Projects/InstaPy/instapy/instapy.py", line 777, in like_by_tags self.logfolder) File "/home/pi/Projects/InstaPy/instapy/unfollow_util.py", line 348, in follow_user follow_button.click() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 72, in click self._execute(Command.CLICK_ELEMENT) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 461, in _execute return self._parent.execute(command, params) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute self.error_handler.check_response(response) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with Stacktrace: at fxdriver.preconditions.visible (file:///tmp/tmpTDio6K/extensions/[email protected]/components/command-processor.js:10092) at DelayedCommand.prototype.checkPreconditions_ (file:///tmp/tmpTDio6K/extensions/[email protected]/components/command-processor.js:12644) at DelayedCommand.prototype.executeInternal_/h (file:///tmp/tmpTDio6K/extensions/[email protected]/components/command-processor.js:12661) at fxdriver.Timer.prototype.setTimeout/<.notify (file:///tmp/tmpTDio6K/extensions/[email protected]/components/command-processor.js:625)

I am getting the same error while running a python script. I can not change the script, Is anybody can suggest, how to resolve this?

selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
(Session info: chrome=64.0.3282.140)
(Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.14393 x86_64)

hi guy any one can help me with this ! get it some time

Traceback (most recent call last):
File "../quickstart.py", line 126, in
interact=True,)
File "C:\Users\Amir\AppData\Local\Programs\Python\Python37-32\lib\site-packages\instapy\instapy.py", line 3240, in follow_user_followers
self.logfolder)
File "C:\Users\Amir\AppData\Local\Programs\Python\Python37-32\lib\site-packages\instapy\unfollow_util.py", line 1084, in get_given_user_followers
logger, logfolder)
File "C:\Users\Amir\AppData\Local\Programs\Python\Python37-32\lib\site-packages\instapy\unfollow_util.py", line 807, in get_users_through_dialog
dialog = browser.find_element_by_xpath(dialog_address)
File "C:\Users\Amir\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\Amir\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\Users\Amir\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\Amir\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//body/div[3]/div/div[2]"}
(Session info: chrome=77.0.3865.90)
(Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.18362 x86_64)

Press any key to continue . . .

Was this page helpful?
0 / 5 - 0 ratings