Instapy: Unable to locate element

Created on 6 May 2018  Â·  12Comments  Â·  Source: timgrossmann/InstaPy

Expected Behavior

settings

    session.set_relationship_bounds(enabled=True,
                 potency_ratio=-1.01,
                  delimit_by_numbers=False,
                   max_followers=20000,
                    max_following=20000,
                     min_followers=10,
                      min_following=10)
    session.set_do_comment(True, percentage=50)
    session.set_do_like(True, percentage=70)
    session.set_do_follow(True, percentage=100)
    session.set_user_interact(amount=1, randomize=False, percentage=100, media='Photo')
    session.set_comments(["a","b","c","d"])

action
session.interact_user_followers(['manuelferrara'], amount=100, randomize=False)

Current Behavior

Traceback (most recent call last):
  File ".\quickstart_complete.py", line 69, in <module>
    session.interact_user_followers(['manuelferrara'], amount=100, randomize=False)
  File "C:\Users\Val\Desktop\InstaPy\instapy\instapy.py", line 1544, in interact_user_followers
    self.logger)
  File "C:\Users\Val\Desktop\InstaPy\instapy\unfollow_util.py", line 663, in get_given_user_followers
    "//div[text()='Followers']/following-sibling::div")
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 293, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 752, in find_element
    'value': value})['value']
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[text()='Followers']/following-sibling::div"}
  (Session info: chrome=65.0.3325.181)
  (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.16299 x86_64)
wontfix

All 12 comments

seeing this too

Same thing.

I run Instapy on Raspberry 2. I started recetly, it worked fine then it crashed. I did a pull update today, then I ran the script, it worked for only one unfollow:

ERROR [2018-05-07 22:33:41] [j.oseph.paris] unfollow error username j.oseph.paris might be blocked INFO [2018-05-07 22:33:41] [j.oseph.paris] --> Total people unfollowed : 1 INFO [2018-05-07 22:33:42] [j.oseph.paris] Session ended - 2018-05-07 22:33:42 INFO [2018-05-07 22:33:42] [j.oseph.paris] --------------------

then I tried again and it crashed:

Traceback (most recent call last): File "/home/pi/instagram-bot/InstaPy/quickstart.py", line 42, in <module> session.unfollow_users(amount=5, onlyInstapyMethod = 'FIFO', sleep_delay=600, unfollow_after=24*60*60) File "/home/pi/instagram-bot/InstaPy/instapy/instapy.py", line 1738, in unfollow_users self.logfolder) File "/home/pi/instagram-bot/InstaPy/instapy/unfollow_util.py", line 327, in unfollow "//div[text()='Following']/following-sibling::div") File "/usr/local/lib/python2.7/dist-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 293, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "/usr/local/lib/python2.7/dist-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 752, in find_element 'value': value})['value'] File "/usr/local/lib/python2.7/dist-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 236, in execute self.error_handler.check_response(response) File "/usr/local/lib/python2.7/dist-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.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[text()='Following']/following-sibling::div"} (Session info: chrome=63.0.3239.84) (Driver info: chromedriver=2.33 (undefined),platform=Linux 4.14.34-v7+ armv7l)

Same issue running on RPI 3 using Firefox.

I'm not seeing the account Followers component open, but I don't see any issue with the below code

    try:
        following_link = browser.find_element_by_xpath(
            '//a[@href="/' + user_name.lower() + '/followers/"]')
    except NoSuchElementException:
        logger.error('Could not find followers link for {}'.format(user_name))
        return
    click_element(browser, following_link)

But if the account follower component does not open then the xpath selector can't find the sibling div per the next piece of code

    dialog = browser.find_element_by_xpath(
        "//div[text()='Followers']/following-sibling::div")

Need someone's help that is more familiar with the unfollow_util.py file and Xpath selectors than myself. @timgrossmann @sionking

Not sure what is going on with this issue, but it could have been an A|B test by instagram. The bot is working fine now, with no code changes after not being able to run for 2 days.

I'm seeing this issue too. It's been happening for the past several days for me now.

Errors from the browser console

[WEBDRIVER] [WARNING] [fxdriver.Utils] Found clickable point in rect [object DOMRect]

[WEBDRIVER] [INFO] [fxdriver.SyntheticMouse] SyntheticMouse.move https://www.instagram.com/pcski/followers/ 104 9

[WEBDRIVER] [INFO] [fxdriver.SyntheticMouse] Calling mouse.move with: 104, 9, https://www.instagram.com/pcski/followers/

[WEBDRIVER] [INFO] [fxdriver.SyntheticMouse] Calling fireMouseEvent mousemove 312.78334045410156, 24, https://www.instagram.com/pcski/followers/

[WEBDRIVER] [INFO] [fxdriver.SyntheticMouse] SyntheticMouse.click https://www.instagram.com/pcski/followers/

[WEBDRIVER] [INFO] [fxdriver.Utils] Not loading document anymore.

[WEBDRIVER] [INFO] [fxdriver.nsCommandProcessor] Received command: getElementAttribute

[WEBDRIVER] [INFO] [fxdriver.nsCommandProcessor] Received command: executeScript

[WEBDRIVER] [INFO] [fxdriver.nsCommandProcessor] Received command: findElement

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at ‘https://graph.instagram.com/logging_client_events’. (Reason: Credential is not supported if the CORS header ‘Access-Control-Allow-Origin’ is ‘*’). (unknown)
1526476024284   addons.manager  INFO    Skipping background update check
1526476264360   addons.xpi  DEBUG   Add-on [email protected] blocks e10s rollout.
1526476264362   DeferredSave.extensions.json    DEBUG   Save changes
1526476264369   DeferredSave.extensions.json    DEBUG   Starting timer
1526476264407   DeferredSave.extensions.json    DEBUG   Starting write
1526476264422   DeferredSave.extensions.json    DEBUG   Write succeeded
Use of getAttributeNode() is deprecated. Use getAttribute() instead.  amo-06ccf259ed4a9a676e98.js:1:870393
[WEBDRIVER] [INFO] [fxdriver.Utils] New page loading.

Use of getAttributeNode() is deprecated. Use getAttribute() instead.

Researching these errors, but could use some help from someone more knowledgeable than myself.

@uluQulu I just did a git pull with the latest merge and this issue persists. Any ideas?

@gitpatrickhub
Make sure you have pulled #2042 properly and then post the screenshot of the error you are getting in console output.

Hi, pulled #2042 but same error here
Running Instapy on Raspberry Pi 3

File "/home/pi/InstaPy/instapy/instapy.py", line 2023, in follow_user_followers self.logfolder) File "/home/pi/InstaPy/instapy/unfollow_util.py", line 879, in get_given_user_followers simulation, channel, logger, logfolder) File "/home/pi/InstaPy/instapy/unfollow_util.py", line 626, in get_users_through_dialog "//div[text()='Followers' or text()='Following']/following-sibling::div") File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 293, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 752, in find_element 'value': value})['value'] 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.NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":"//div[text()='Followers' or text()='Following']/following-sibling::div"} Stacktrace: at FirefoxDriver.prototype.findElementInternal_ (file:///tmp/tmpwxiJjq/extensions/[email protected]/components/driver-component.js:10770) at fxdriver.Timer.prototype.setTimeout/<.notify (file:///tmp/tmpwxiJjq/extensions/[email protected]/components/driver-component.js:625)

Tried changing

following_link = browser.find_elements_by_xpath( '//section//ul//li[3]')
to

following_link = browser.find_elements_by_xpath( '//li[3]')

but no success

2219

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. > If this problem still occurs, please open a new issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ingorichter picture ingorichter  Â·  3Comments

neomh picture neomh  Â·  3Comments

tibor picture tibor  Â·  3Comments

ghost picture ghost  Â·  3Comments

Spyd3r0us picture Spyd3r0us  Â·  3Comments