Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I'm trying to write scripts to download relevant data from my Wells Fargo account, and using Selenium within a python script seems like a good potential solution. However, when I try to log in, I get redirected to a different login screen, which keeps redirecting to itself each time I try to log in again. How do I get past this infinite redirect?

The simplest way to reproduce this is to run this script to open a selenium Chrome browser:

import selenium

browser = selenium.webdriver.Chrome()

browser.get('https://www.google.com/')

Then manually log in. On a normal browser, this works fine. In the selenium browser, I get the redirect page.

1 Answer

0 votes
by (62.9k points)

Try this code:

from selenium.webdriver import Chrome

browser = Chrome()

browser.get('https://google.com')

#GET user element and POST username to element

user = browser.find_element_by_id('userid'

)

user.

send_keys('USERNAME')

#GET user element and POST password to element

passwd = browser.find_element_by_id('password')

passwd.send_keys('PASSWORD')

passwd.submit()

You should be logged in and redirected to account page. Please tell me how it works out for you.

Browse Categories

...