How to test a huge list of domains redirect to HTTPS?



  • I have got a huge list of domains/URLs (about a 1000). The task is to test if each one of them, if accessed with http://domain.com then it redirects to https://domain.com.

    All the domains that do not redirect are to be reported to devs.

    One way of doing this would be,

    1. To open each URL with Selenium WebDriver's get(url); method.
    2. To get the current URL from the browser using getCurrentUrl();.
    3. Compare the to to ensure the latter begins with HTTPS.

    But, I guess there should be a faster way to do this without needing to use Selenium.

    Any ideas?



  • You can use CURL for it. For instance, if you run

    curl -Ls -o /dev/null -w %{url_effective} http://sqa.stackexchange.com/
    

    it will show https://sqa.stackexchange.com/, which is the redirected URL.

    The flags mean the following:

    -L         Follow redirects
    -s         Silent mode. Don't output anything
    -o FILE    Write output to FILE instead of stdout
    -w FORMAT  What to output after completion (url_effective is the final URL)
    

    With some simple scripting, you can check if the returned strings form CURL start with https




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2