Python Forum
Python-selenium script for automated web-login does not work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python-selenium script for automated web-login does not work
#1
Objective is to login into a website, pass some search parameters and open top 3 results.
However, I am stuck at the first step. Using Python 3.7 on Spyder (Anaconda). Individual commands work fine on console.

However, after the last command, browser throws following error: "Sorry, we could not authenticate you. Try again."

The Log In page however is a redirection from the URL below, to "https://accounts.sap.com/saml2/idp/sso/accounts.sap.com".
However, since the elements are located correctly and values passed, I suppose that isn't an issue. Clueless, why does the browser not accept login. Any support would be greatly appreciated.

Browser response is consistent in both Chrome and Firefox.

import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

url="https://launchpad.support.sap.com"

browser = webdriver.Firefox()
browser.get(url)

time.sleep(10)
loginElem=browser.find_element_by_id("j_username")
pwdElem=browser.find_element_by_id("j_password")
submitElem=browser.find_element_by_id("logOnFormSubmit")

loginElem.clear()
loginElem.send_keys=('UserIDXXXXXX')
pwdElem.clear()
pwdElem.send_keys=('PasswordXXXXX')
submitElem.click()
Reply
#2
I figured that the problem lies with "send_keys". It is not populating the fields, leaving it empty and hence the error.

Now, I am using latest Selenium and Python versions, not sure what else could be causing the issue. Any suggestions?
Reply
#3
it should be loginElem.send_keys('UserIDXXXXXX')
what you do is to assign a string to loginElem.send_keys property thus overriding the method
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Script does not work on Linux server scrapemasta 0 105 Mar-22-2024, 11:07 AM
Last Post: scrapemasta
  How do I get rid of "Chrome is being controlled by automated test software"? jetBlack 2 12,541 Jul-21-2022, 08:31 AM
Last Post: Benjamin112
  I want to create an automated website in python mkdhrub1 2 2,310 Dec-27-2021, 11:27 PM
Last Post: Larz60+
  little parser-script crashes after doing good work for some time apollo 0 1,628 Feb-03-2021, 10:48 AM
Last Post: apollo
  Selenium google login probottpric 0 2,148 Oct-09-2020, 04:19 PM
Last Post: probottpric
  how to add a login to a bs4 parser-script apollo 10 8,137 Jul-02-2020, 10:47 PM
Last Post: snippsat
  Python Webscraping with a Login Website warriordazza 0 2,571 Jun-07-2020, 07:04 AM
Last Post: warriordazza
  How to perform a successful login(signin) through Requests in Python Kalet 1 2,304 Apr-24-2020, 01:44 AM
Last Post: Larz60+
  HOWTO? Login DSL Modem with Python Requests: need Click "Apply" Button Webtest 4 8,406 Aug-20-2019, 04:03 PM
Last Post: johnmina
  Automated Git add/commit/push rxndy 0 1,991 May-13-2019, 11:51 AM
Last Post: rxndy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020