Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP url redirects as HTTPS on selenium test run

Tags:

When I pass an URL to load a website, say, http://yoururl.com, it redirects to https://yoururl.com

I mean, passing an URL with HTTP automatically redirects as https://yoururl.com in the browser URL.

@driver.get("http://yoururl.com")

Browser used: Chrome

Is there a way to stop redirecting the HTTP url as HTTPS?

like image 725
Ruby Tester Avatar asked Dec 14 '17 12:12

Ruby Tester


2 Answers

The Chrome 63 and above versions will no longer take HTTP with domain .dev since you are in the local/dev environment.

https://iyware.com/dont-use-dev-for-development/

Chrome 63 (out since December 2017), will force all domains ending on .dev (and .foo) to be redirected to HTTPS via a preloaded HTTP Strict Transport Security (HSTS) header https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/

like image 148
Prashanth Sams Avatar answered Sep 20 '22 13:09

Prashanth Sams


There are couple of reasons this would happen.

  1. Redirection at load balancer or reverse proxy level. This can be fixed by altering web server or LB configuration.
  2. As browsers getting smarter everyday, when you open an https url is browser then next time if you even want to open http url it'll by default go to https because browser already knows that the site supports https as well. So it'll prefer to use secured communication rather text when it is available.

Here is some help for second case https://superuser.com/questions/565409/chrome-how-to-stop-redirect-from-http-to-https

like image 27
kakurala Avatar answered Sep 22 '22 13:09

kakurala