Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login A/B test detected! Trying another string... #274

Open
imager777 opened this issue Nov 2, 2022 · 7 comments
Open

Login A/B test detected! Trying another string... #274

imager777 opened this issue Nov 2, 2022 · 7 comments

Comments

@imager777
Copy link

I'm new to using InstaPy, but I gathered that this issue comes from login_util.py and it not being able to locate the Log In element. I attached a screenshot of how my login window appears.

Any insight on a way to get around this would be awesome!

starting instapy with quickstart

InstaPy Version: 0.6.16
.. .. .. .. .. .. .. .. ._.
Workspace in use: "C:/Users/vboxuser/InstaPy"
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
INFO [2022-11-01 20:34:40] [username] Session started!
oooooooooooooooooooooooooooooooooooooooooooooooooooooo
INFO [2022-11-01 20:34:45] [username] - Cookie file not found, creating cookie...
WARNING [2022-11-01 20:34:56] [username] Login A/B test detected! Trying another string...
WARNING [2022-11-01 20:35:01] [username] Could not pass the login A/B test. Trying last string...
ERROR [2022-11-01 20:35:06] [username] Login A/B test failed!
b"Message: Unable to locate element: //div[text()='Log In']\nStacktrace:\nRemoteError@chrome://remote/content/shared/RemoteError.jsm:12:1\nWebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:192:5\nNoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:404:5\nelement.find/</<@chrome://remote/content/marionette/element.js:291:16\n"
Traceback (most recent call last):
File "C:\Users\vboxuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\instapy\login_util.py", line 337, in login_user
login_elem = browser.find_element(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vboxuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 856, in find_element
return self.execute(Command.FIND_ELEMENT, {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vboxuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 429, in execute
self.error_handler.check_response(response)
File "C:\Users\vboxuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, 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.jsm:12:1
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:192:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:404:5
element.find/</<@chrome://remote/content/marionette/element.js:291:16

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\vboxuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\instapy\login_util.py", line 343, in login_user
login_elem = browser.find_element(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vboxuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 856, in find_element
return self.execute(Command.FIND_ELEMENT, {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vboxuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 429, in execute
self.error_handler.check_response(response)
File "C:\Users\vboxuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, 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.jsm:12:1
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:192:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:404:5
element.find/</<@chrome://remote/content/marionette/element.js:291:16

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\vboxuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\instapy\login_util.py", line 350, in login_user
login_elem = browser.find_element(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vboxuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 856, in find_element
return self.execute(Command.FIND_ELEMENT, {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vboxuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 429, in execute
self.error_handler.check_response(response)
File "C:\Users\vboxuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, 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.jsm:12:1
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:192:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:404:5
element.find/</<@chrome://remote/content/marionette/element.js:291:16
InstaPyLoginWindowError

@zRelux
Copy link

zRelux commented Nov 10, 2022

Same

@ecoyork-mlane
Copy link

Does this mean this project is dead? Any alternative anyone has come across for instagram?

@taimoorkhokhar
Copy link

inside the instapy source code theres a file which has all the associated xpaths for elements, I have manually inspected the login element Text its now "Log in" instead of "Log In".

Fix:
open instapy/xpath_compile.py

Change:
"login_elem": "//button[text()='Log In']",

to

"login_elem": "//button[text()='Log in']",

@billpsomas
Copy link

Thank you! That worked for me!

@Robertefendi02
Copy link

inside the instapy source code theres a file which has all the associated xpaths for elements, I have manually inspected the login element Text its now "Log in" instead of "Log In".

Fix: open instapy/xpath_compile.py

Change: "login_elem": "//button[text()='Log In']",

to

"login_elem": "//button[text()='Log in']",

Thanks a lot. It worked for me too!

@tommaso-gallo
Copy link

inside the instapy source code theres a file which has all the associated xpaths for elements, I have manually inspected the login element Text its now "Log in" instead of "Log In".

Fix: open instapy/xpath_compile.py

Change: "login_elem": "//button[text()='Log In']",

to

"login_elem": "//button[text()='Log in']",

I solved it in a similar way. On the same file, two lines after this there is the line:

"login_elem_no_such_exception_2": "//div[text()='Log In']",

make the same change (Log In --> Log in).

I am not sure why for me is different but I just solved it by inspecting the button on the instagram page and noticing it was not defined as a button but as a div

@defconV
Copy link

defconV commented Aug 5, 2023

That one did not work for me. I created some new lines of code, which helped me to fix the issue. This is it: ( it has to be copied into login_util.py.

# Check if the first div is 'Create an Account' or 'Log In'
try:
    login_elem = browser.find_element(
        By.XPATH, read_xpath(login_user.__name__, "login_elem")
    )
except NoSuchElementException:
    logger.warning("Login A/B test detected! Trying another string...")
    try:
        login_elem = browser.find_element(
            By.XPATH,
            read_xpath(login_user.__name__, "login_elem_no_such_exception"),
        )
    except NoSuchElementException:
        logger.warning("Could not pass the login A/B test. Trying last string...")
        try:
            login_elem = browser.find_element(
                By.XPATH,
                read_xpath(login_user.__name__, "login_elem_no_such_exception_2"),
            )

        except NoSuchElementException:
            logger.warning("DevconV method initialized")
            try:
                login_elem = browser.find_element(
                    By.XPATH, "//button[text()='Log in']")

            except NoSuchElementException:
                logger.warning("DevconV is trying again")
                try:
                    login_elem = browser.find_element(
                        By.XPATH, "//div[@class='_aacl _aaco _aacw _aad0 _aad6' and text()='Log in']")

                except NoSuchElementException as e:
                    # NF: start
                    logger.exception(
                        "Login A/B test failed!\n\t{}".format(str(e).encode("utf-8"))
                    )
                    return False
                    # NF: end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants