InstaPy / InstaPy

📷 Instagram Bot - Tool for automated Instagram interactions
GNU General Public License v3.0
16.74k stars 3.77k forks source link

Error while accepting cookies #6701

Closed systenconti closed 1 year ago

systenconti commented 1 year ago

Current Behavior

App doesn't log in. It opens a website and gets stuck while accepting cookies. I'm still learning python so I'm kinda hardstuck. I guess the error is occuring, because it's not able to fill in the login and password gaps due to Allow cookies screen. Let me know how to cope with it.

InstaPy configuration

InstaPy Version: 0.6.16 .. .. .. .. .. .. .. .. ._. Workspace in use: "C:/Users/barto/InstaPy" OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO INFO [2023-04-02 01:41:20] [montyandmacythegoldens] Session started! oooooooooooooooooooooooooooooooooooooooooooooooooooooo INFO [2023-04-02 01:41:23] [montyandmacythegoldens] - Cookie file not found, creating cookie... WARNING [2023-04-02 01:41:33] [montyandmacythegoldens] Login A/B test detected! Trying another string... WARNING [2023-04-02 01:41:38] [montyandmacythegoldens] Could not pass the login A/B test. Trying last string... ERROR [2023-04-02 01:41:43] [montyandmacythegoldens] Login A/B test failed! b"Message: Unable to locate element: //div[text()='Log In']\nStacktrace:\nRemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8\nWebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:180:5\nNoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:392:5\nelement.find/</<@chrome://remote/content/marionette/element.sys.mjs:134:16\n" Traceback (most recent call last): File "C:\Users\barto\InstagramBOT.venv\Lib\site-packages\instapy\login_util.py", line 337, in login_user login_elem = browser.find_element( ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\barto\InstagramBOT.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 831, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\barto\InstagramBOT.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute self.error_handler.check_response(response) File "C:\Users\barto\InstagramBOT.venv\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //button[text()='Log In'] Stacktrace: RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8 WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:180:5 NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:392:5 element.find/</<@chrome://remote/content/marionette/element.sys.mjs:134:16

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\barto\InstagramBOT.venv\Lib\site-packages\instapy\login_util.py", line 343, in login_user login_elem = browser.find_element( ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\barto\InstagramBOT.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 831, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\barto\InstagramBOT.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute self.error_handler.check_response(response) File "C:\Users\barto\InstagramBOT.venv\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //a[text()='Log in'] Stacktrace: RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8 WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:180:5 NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:392:5 element.find/</<@chrome://remote/content/marionette/element.sys.mjs:134:16

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\barto\InstagramBOT.venv\Lib\site-packages\instapy\login_util.py", line 350, in login_user login_elem = browser.find_element( ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\barto\InstagramBOT.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 831, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\barto\InstagramBOT.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute self.error_handler.check_response(response) File "C:\Users\barto\InstagramBOT.venv\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //div[text()='Log In'] Stacktrace: RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8 WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:180:5 NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:392:5 element.find/</<@chrome://remote/content/marionette/element.sys.mjs:134:16

.................................................................................................................................... CRITICAL [2023-04-02 01:41:43] [montyandmacythegoldens] Unable to login to Instagram! You will find more information in the logs above. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

INFO [2023-04-02 01:41:46] [montyandmacythegoldens] Sessional Live Report: |> No any statistics to show

[Session lasted 31.97 seconds] OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO INFO [2023-04-02 01:41:46] [montyandmacythegoldens] Session ended! ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

jlo386 commented 1 year ago

In the file xpath_compile.py change

xpath["accept_igcookie_dialogue"] = {"accept_button": "//button[text()='Accept']"} to xpath["accept_igcookie_dialogue"] = {"accept_button": "//button[text()='Allow all cookies']"}

and in the same file, rename every instance where it reads "Log In" to "Log in" (lowercase i)

ludegrev commented 1 year ago

it worked for me! thank you @jlo386

systenconti commented 1 year ago

Yeah it worked for me too, thanks