Instapy: (XPATH issue?) Still Impossible to interact_user_followers (crash)

Created on 5 Apr 2019  路  6Comments  路  Source: timgrossmann/InstaPy

Basic config:

def job():
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=False,
multi_logs=True)

try:
    session.login()

    # settings
    session.set_relationship_bounds(enabled=True,
                 potency_ratio=None,
                  delimit_by_numbers=True,
                   max_followers=10000,
                    max_following=10000,
                     min_followers=100,
                      min_following=200)
    session.set_user_interact(amount=5, randomize=True, percentage=50, media='Photo')
    session.set_simulation(enabled=True, percentage=66)
    session.set_do_like(enabled=True, percentage=70)
    session.set_comments(["Cool", "Super!"])
    session.set_do_comment(enabled=True, percentage=80)
    session.interact_user_followers(['natgeo'], amount=10, randomize=True)
except Exception as exc:
    # if changes to IG layout, upload the file to help us locate the change
    if isinstance(exc, NoSuchElementException):
        file_path = os.path.join(gettempdir(), '{}.html'.format(time.strftime('%Y%m%d-%H%M%S')))
        with open(file_path, 'wb') as fp:
            fp.write(session.browser.page_source.encode('utf8'))
        print('{0}\nIf raising an issue, please also upload the file located at:\n{1}\n{0}'.format(
            '*' * 70, file_path))
    # full stacktrace when raising Github issue
    raise

finally:
    # end the bot session
    session.end()

Output crash:

Traceback (most recent call last):
File "C:\Python\InstaPy-master\Basic follow-unfollow activity.py", line 43, in

session.interact_user_followers(['natgeo'], amount=10, randomize=True)
File "C:\Python\InstaPy-master\instapy\instapy.py", line 2801, in interact_use
r_followers
self.logfolder)
File "C:\Python\InstaPy-master\instapy\unfollow_util.py", line 1082, in get_gi
ven_user_followers
logger, logfolder)
File "C:\Python\InstaPy-master\instapy\unfollow_util.py", line 810, in get_use
rs_through_dialog
dialog = browser.find_element_by_xpath(dialog_address)
File "C:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", lin
e 385, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", lin
e 955, in find_element
'value': value})['value']
File "C:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", lin
e 312, in execute
self.error_handler.check_response(response)
File "C:\Python\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: Una
ble to locate element: {"method":"xpath","selector":"//body/div[2]/div/div[2]"}
(Session info: chrome=73.0.3683.103)
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361
e1),platform=Windows NT 6.3.9600 x86_64)

wontfix

Most helpful comment

I tried to change, in C:\Python\InstaPy-master\instapy\unfollow_util.py line 810

dialog_address = "//body/div[2]/div/div[2]"

in

dialog_address = "//body/div[3]/div/div[2]"

I thought that worked, but I still had some issue every now and then.
Then i changed to

dialog_address = "//body/div[@role='presentation']/div/div[2]"

And it seems to work better. But this is a temporary solution.

All 6 comments

I tried to change, in C:\Python\InstaPy-master\instapy\unfollow_util.py line 810

dialog_address = "//body/div[2]/div/div[2]"

in

dialog_address = "//body/div[3]/div/div[2]"

I thought that worked, but I still had some issue every now and then.
Then i changed to

dialog_address = "//body/div[@role='presentation']/div/div[2]"

And it seems to work better. But this is a temporary solution.

awesome man, this fixed it! How come it is not implemented in the build yet...

Worked for me too

I try to change : Edit unfollow_util.py (line 809)
https://github.com/timgrossmann/InstaPy/blob/master/instapy/unfollow_util.py#L809

Old
dialog_address = "//body/div[3]/div/div[2]"

New
dialog_address = "//body/div[@ROLE="presentation"]/div/div[2]"

But same error

Still have this error in the main repository

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

ediooo picture ediooo  路  3Comments

converge picture converge  路  3Comments

ingorichter picture ingorichter  路  3Comments

CodeMaster1 picture CodeMaster1  路  3Comments

thisishotdog picture thisishotdog  路  3Comments