Instapy: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//form/span/button[text()='Log in']"}

Created on 26 Sep 2018  路  13Comments  路  Source: timgrossmann/InstaPy

@uluQulu and @sionking , any suggestions?

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
INFO [2018-09-26 20:12:58] [xxx] Session started!
ooooooooooooooooooooooooooooooooooooooooooooooooooooooo

Cookie file not found, creating cookie...


If raising an issue, please also upload the file located at:
/tmp/20180926-201355.html


INFO [2018-09-26 20:13:55] [xxx] Sessional Live Report:
|> LIKED 0 images | ALREADY LIKED: 0
|> COMMENTED on 0 images
|> FOLLOWED 0 users | ALREADY FOLLOWED: 0
|> UNFOLLOWED 0 users
|> INAPPROPRIATE images: 0
|> NOT VALID users: 0
currently FOLLOWING 0 users & has got 0 FOLLOWERS

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
INFO [2018-09-26 20:13:55] [xxx] Session ended!
ooooooooooooooooooooooooooooooooooooooooooooooooooooo

Traceback (most recent call last):
File "5baaaa126a0bb9001392b800.py", line 16, in
session.login()
File "/home/fredrik/InstaPy/instapy/instapy.py", line 385, in login
self.bypass_suspicious_attempt):
File "/home/fredrik/InstaPy/instapy/login_util.py", line 239, in login_user
"//form/span/button[text()='Log in']")
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 393, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 966, in find_element
'value': value})['value']
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.6/dist-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":"//form/span/button[text()='Log in']"}
(Session info: headless chrome=69.0.3497.100)
(Driver info: chromedriver=2.36 (7165af0ca9863529f28e493568ae3d105eddcdef),platform=Linux 4.15.0-34-generic x86_64)

wontfix

Most helpful comment

Update xpath to "//button[text()='Log in']" in login_util.py line 239.

All 13 comments

Same error here, just one accout having these trouble, others are ok

Update xpath to "//button[text()='Log in']" in login_util.py line 239.

Thats works, I gonna try others now...

@osvald0 thanks mate!

I made a real quick PR, thank you @osvald0.

In my case, I changed the .click() to .send_keys(Keys.ENTER) and I was able to login.
File: login_util.py
Line: 239

# login_button = browser.find_element_by_xpath(
#     "//form/span/button[text()='Log in']")

# (ActionChains(browser)
#     .move_to_element(login_elem)
#     .click()
#     .perform())

(ActionChains(browser)
    .move_to_element(input_password[0])
    .click()
    .send_keys(Keys.ENTER)
    .perform())

You are no longer looking for the Log in button text that triggers the error.
Instead you focus the password box and press enter, like must human would do.
Voila, you are login.

Sounds human ahaha, nice intuition!

Update xpath to "//button[text()='Log in']" in login_util.py line 239.

In my file there are 181 lines.

It fills the username + pass and says "Cookie file not found, creating cookie...", after a while stops.

I changed back to old account and worked.

{"method":"xpath","selector":"//form/span/button[text()='Log in']"}
still not working. It fills the username in one signup session and password in another login session
kindly suggest me.

Change
login_button = browser.find_element_by_xpath( "//form/span/button[text()='Log in']")

to
login_button = browser.find_element_by_xpath( "//*[contains(text(), 'Log in')]")

in login_util.py

Change
login_button = browser.find_element_by_xpath( "//form/span/button[text()='Log in']")

to
login_button = browser.find_element_by_xpath( "//*[contains(text(), 'Log in')]")

in login_util.py

does not work

In my case, I changed the .click() to .send_keys(Keys.ENTER) and I was able to login.
File: login_util.py
Line: 239

# login_button = browser.find_element_by_xpath(
#     "//form/span/button[text()='Log in']")

# (ActionChains(browser)
#     .move_to_element(login_elem)
#     .click()
#     .perform())

(ActionChains(browser)
    .move_to_element(input_password[0])
    .click()
    .send_keys(Keys.ENTER)
    .perform())

You are no longer looking for the Log in button text that triggers the error.
Instead you focus the password box and press enter, like must human would do.
Voila, you are login.

This works, but you also need to add from selenium.webdriver.common.keys import Keys to the beginning of the file.

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

46960 picture 46960  路  3Comments

rahulkapoor90 picture rahulkapoor90  路  3Comments

converge picture converge  路  3Comments

harrypython picture harrypython  路  3Comments

Spyd3r0us picture Spyd3r0us  路  3Comments