简体   繁体   中英

ERR_TOO_MANY_REDIRECTS error while trying to login through a webpage that uses frames and Javascript using Selenium and Python

I am trying to automate my login to a webpage to download a daily xml. I understand that I need to have the actual frame url I think is

http://shop.braintrust.gr/shop/store/customerauthenticateform.asp

I examine the form and the fields and I do the following

browser = webdriver.Chrome('C:\\chromedriver.exe')
browser.get('http://shop.braintrust.gr/shop/store/customerauthenticateform.asp')
print('Browser Opened')
username = browser.find_element_by_name('UserID')
username.send_keys(email)
password = browser.find_element_by_name('password')
# time.sleep(2)
password.send_keys(pwd)

but I get a blank page saying that browser did a lot of redirections this means that it is impossible to login? How can I login? thank you

ERR_TOO_MANY_REDIRECTS

ERR_TOO_MANY_REDIRECTS (also known as a redirect loop) is one of the regular website errors. Typically this error occurs after a recent change to your website, a mis-configuration of redirects on your server or wrong settings with third-party services.

This error have no relation with Selenium as such and can be reproduced through Manual Steps .

The reason for ERR_TOO_MANY_REDIRECTS is that, something is causing your website to go into an infinite redirection loop . Essentially the site is stuck (such as URL 1 points to URL 2 and URL 2 points back to URL 1 , or the domain has redirected you too many times) and unlike some other errors, these rarely resolve themselves and will probably need you to take action to fix it. There are a couple different variations of this error depending upon the browser you're running.


Solution

Some common approach to check and fix the error as as follows:

  • Delete Cookies on That Specific Site : Google and Mozilla both in fact recommends right below the error to try clearing your cookies. Cookies can sometimes contain faulty data in which could cause the ERR_TOO_MANY_REDIRECTS error. This is one recommendation you can try even if you're encountering the error on a site you don't own. Due to the fact that cookies retain your logged in status on sites and other settings, in these cases simply deleting the cookie(s) on the site that is having the problem. This way you won't impact any of your other sessions or websites that you frequently visit.
  • Clear Browser Cache : If you want to check and see if it might be your browser cache, without clearing your cache, you can always open up your browser in incognito mode. Or test another browser and see if you still see the ERR_TOO_MANY_REDIRECTS error.
  • Determine Nature of Redirect Loop : If clearing the cache didn't work, then you'll want to see if you can determine the nature of the redirect loop. For example, if a site has a 301 redirect loop back to itself, which is causing a large chain of faulty redirects. You can follow all the redirects and determine whether or not its looping back to itself, or perhaps is an HTTP to HTTPS loop.
  • Check Your HTTPS Settings : Another thing to check is your HTTPS settings. A lot of times it is observed ERR_TOO_MANY_REDIRECTS occur when someone has just migrated their WordPress site to HTTPS and either didn't finish or setup something incorrectly.
  • Check Third-Party Services : ERR_TOO_MANY_REDIRECTS is also often commonly caused by reverse-proxy services such as Cloudflare. This usually happens when their Flexible SSL option is enabled and you already have an SSL certificate installed with your WordPress host. Why? Because, when flexible is selected, all requests to your hosting server are sent over HTTP. Your host server most likely already has a redirect in place from HTTP to HTTPS, and therefore a redirect loop occurs.
  • Check Redirects on Your Server : Besides HTTP to HTTPS redirects on your server, it can be good to check and make sure there aren't any additional redirects setup wrong. For example, one bad 301 redirect back to itself could take down your site. Usually, these are found in your server's config files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM