instapy-quickstart icon indicating copy to clipboard operation
instapy-quickstart copied to clipboard

Error "Cookie file not found, creating cookie..."

Open Xen-neX opened this issue 4 years ago • 11 comments

InstaPy Version: 0.6.12 .. .. .. .. .. .. .. .. Workspace in use: "/home/xxxxxxx/InstaPy" INFO [2020-12-18 15:46:19] [xxxxxxx] Session started! OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO oooooooooooooooooooooooooooooooooooooooooooooooooooooo INFO [2020-12-18 15:46:19] [xxxxxxx] -- Connection Checklist [1/2] (Internet Connection Status) INFO [2020-12-18 15:46:21] [xxxxxxx] - Internet Connection Status: ok INFO [2020-12-18 15:46:21] [xxxxxxx] - Current IP is "195.246.120.63" and it's from "Sweden/SE" INFO [2020-12-18 15:46:21] [xxxxxxx] -- Connection Checklist [2/2] (Hide Selenium Extension) INFO [2020-12-18 15:46:21] [xxxxxxx] - window.navigator.webdriver response: None INFO [2020-12-18 15:46:21] [xxxxxxx] - Hide Selenium Extension: ok Cookie file not found, creating cookie... INFO [2020-12-18 15:47:05] [xxxxxxx] Timed out with failure while explicitly waiting until visibility of element located!

Traceback (most recent call last): File "xxxxxxx/main.py", line 38, in InstaPy(username="xxxxxxx", password="xxxxxxx").login() File "/usr/local/lib/python3.8/dist-packages/instapy/instapy.py", line 425, in login if not login_user( File "/usr/local/lib/python3.8/dist-packages/instapy/login_util.py", line 316, in login_user input_username = browser.find_element_by_xpath(input_username_XP) File "/usr/local/lib/python3.8/dist-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/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element return self.execute(Command.FIND_ELEMENT, { File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //input[@name='username']

https://ibb.co/VMSKDNw

Xen-neX avatar Dec 18 '20 12:12 Xen-neX

Thanks for sharing, the pic is referring to a new feature (page) that IG is using to track some user activities. Last PR was intended to handle that new page, did you use the latest commit from git? It is 0.6.12 but with extra commits.

elulcao avatar Dec 22 '20 19:12 elulcao

Thanks for sharing, the pic is referring to a new feature (page) that IG is using to track some user activities. Last PR was intended to handle that new page, did you use the latest commit from git? It is 0.6.12 but with extra commits.

I work through a virtual environment in PyCharm, install also through PyCharm.

Xen-neX avatar Jan 01 '21 08:01 Xen-neX

Still having this problem. Simply due to a new cookie screen @elulcao referenced to. Any change this will be updated soon? image

CoderGOG avatar Jan 02 '21 10:01 CoderGOG

@CoderGOG This is the new page that must be problem. In my region, is not deployed yet, so I introduced a possible fix in latest commit. Did you use the latest commit?

elulcao avatar Jan 02 '21 15:01 elulcao

Thanks for the answer. I updated the InstaPy python library (still doesn't work after), but that isn't sufficient I suppose?

CoderGOG avatar Jan 02 '21 16:01 CoderGOG

It seems that function accept_igcookie_dialogue(browser, logger) needs to be updated, or this xpath xpath["accept_igcookie_dialogue"] = {"accept_button": "//button[text()='Accept']"} need to be updated also. The main issue, then is just to automate the action for clicking the Accept button.

elulcao avatar Jan 03 '21 02:01 elulcao

@elulcao @CoderGOG what I did was in the function login_user (login_util.py) when cookies can't be loaded, the instagram homepage is loaded again, after which cookies need to be accepted. I added the line:

accept_igcookie_dialogue(browser, logger)

Then it works when logging in.

This is only necessary for the first login when there is no cookie yet.

iampatrickbrinksma avatar Feb 01 '21 19:02 iampatrickbrinksma

@ikbenpatrickbrinksma I guess you are correct. In the geographic zone Im living at, that page has not be released, so I cannot test in my local the function at al. I posted in other issues comments about the issue Im facing, also requested some help to verify the correct functionality; but not response for now. I you can propose a possible fix, please let us now.

elulcao avatar Feb 01 '21 22:02 elulcao

@elulcao I suggest to add the line as I suggested.

Add line:

accept_igcookie_dialogue(browser, logger)

after web_address_navigator(browser, ig_homepage) on line 317

iampatrickbrinksma avatar Feb 01 '21 22:02 iampatrickbrinksma

i keep getting the same error

diogoribeirodev avatar Jun 14 '21 12:06 diogoribeirodev

in xpath_compile.py edit last xpath to "Allow essential and optional cookies"

alirezamdv avatar Aug 29 '22 17:08 alirezamdv