Search code examples
excelautomationheadless-browser

Best Way to Validate Login URL Redirection


Can anyone help me which is the best way to implement below utility where I have around 20 Set of Username and Password and I should login to url Say : http://login.com , If the username/password is proper it will redirect to http://login.com/true else it will redirect to http://login.com/false.

How to Automate this process and track update the status to Excel sheet back which are valid User name and Password combination.

Is there anyway we can automate without opening url in the browser (Kind of headless automation)


Solution

  • You can do all this with shell scripting and no browsers involved. For the

    should login to url

    you can utilize cURL, since it specifically has a feature to follow redirects (-L / --location), and it's also free.

    curl --user user:pass https://example.com/a  
    

    For the part with

    to Automate this process and track update the status to Excel sheet back

    you can use the output from the previous step (the page url) and formatted in a CSV file, like so:

    echo "$page_url" > results.csv
    

    After that you could rename into xls and then with Excel, gnumeric, or other programs, it is recognized like xls.

    ls -R -ltr / | head -50 | awk '{if ($page_url == *"myURL"*) print "true"}' OFS="," > sample.xls
    

    You can find more options for working with Excel files here.