Selenium Unable to locate element
Hi everyone, I hope you guys are doing well : ( I got the last version of commits )
the code I am using:
session.login()
session.set_relationship_bounds(enabled=False,
potency_ratio=-1.21,
delimit_by_numbers=False,
max_followers=4590,
max_following=5555,
min_followers=45,
min_following=77)
session.set_simulation(enabled=False)
session.set_skip_users(skip_private=True,
private_percentage=100,
skip_no_profile_pic=False,
no_profile_pic_percentage=100,
skip_business=False,
business_percentage=100,
skip_business_categories=[],
dont_skip_business_categories=[])
session.set_user_interact(amount=2, randomize=True, percentage=100, media='Photo')
session.set_do_like(enabled=True, percentage=100)
session.interact_user_followers(['user'], amount=1600, randomize=False)
the error I got
Traceback (most recent call last):
File "like.py", line 57, in <module>
session.interact_user_followers(['username'], amount=1600, randomize=False)
File "/Users/user/Desktop/instagram/InstaPy/instapy/instapy.py", line 2801, in interact_user_followers
self.logfolder)
File "/Users/user/Desktop/instagram/InstaPy/instapy/unfollow_util.py", line 1082, in get_given_user_followers
logger, logfolder)
File "/Users/user/Desktop/instagram/InstaPy/instapy/unfollow_util.py", line 810, in get_users_through_dialog
dialog = browser.find_element_by_xpath(dialog_address)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element
'value': value})['value']
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/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[2]/div/div[2]"}
Thank you for helping !
same. might be the HTML changed
I have the same error, I went back to following by tags. I'm presuming the element has changed location on the website.
Got the same error interacting whit the followers of my competitors, theres any solution?
Same issue here.
The dialog_address xpath in the unfollow_util.py needs to be changed. The followers dialog box opens successfully but it gets closed when it tries to scroll
Don't have time to look into it right now, but hope that's a starting point someone can build off of!
File: unfollow_util.py
Solution:
# find dialog box
dialog_address = "//body/div[3]/div/div[2]"
dialog = browser.find_element_by_xpath(dialog_address)
Before:
# find dialog box
dialog_address = "//body/div[2]/div/div[2]"
dialog = browser.find_element_by_xpath(dialog_address)
Thanks @globsecure!!
@globsecure thanks a lot works perfect for me !
@globsecure works here, thanks!
File: unfollow_util.py Solution:
find dialog box
dialog_address = "//body/div[3]/div/div[2]" dialog = browser.find_element_by_xpath(dialog_address)
Before:
find dialog box
dialog_address = "//body/div[2]/div/div[2]" dialog = browser.find_element_by_xpath(dialog_address)
Thanks @globsecure, worked perfectly!
the solution is working, thank you @globsecure, I am closing this thread
Thanks @globsecure for the solution, appreciate it! Quick question however: If I install instapy on a server via pip and then import the library in a Python script, it will still produce this error, right?
I changed it, but now I got this error :
Cookie file not found, creating cookie...
web_1 | Traceback (most recent call last):
web_1 | File "code/docker_quickstart.py", line 14, in
I guess an error is still on the file "Log in"
Thanks @globsecure for the solution, appreciate it! Quick question however: If I install instapy on a server via pip and then import the library in a Python script, it will still produce this error, right?
Yeah...
Using: pip install -e . (Compile local)
BUT:
pip install instapy -U (solution on production)
@globsecure amazing.. thank you.
@globsecure Awesome! Thank you! May one day I understand this stuff as you guys do. :)
Now the issue is change to //body/div[3]/div/div[2] also failed.
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate eleme t: {"method":"xpath","selector":"//body/div[3]/div/div[2]"} (Session info: chrome=73.0.3683.86) (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Window NT 6.1.7601 SP1 x86_64)
I'm new to all this, how do I use the solution given?
@jointyje which OS did you use ?