How to test HTTPS HTTP tunneling using Casper.js?

I need to get test coverage in some of our company extranets, we use phantom.js / casper.js, as it was easiest to integrate with the rest of our test workflow.

The problem occurs when trying to switch from HTTP to HTTPS through tunneling. If users visited our website at http // www.somecompany.com and click on the login link, their browser redirects to https // extranet.somecompany.com. If you look at the HTML source, you will see HTML that correctly matches the form the user was redirected to.

However, when I try to recreate the workflow using casper.js, I successfully trigger the click event on the login link. Then I try to identify the form element to confirm that the redirect was successful, but this test fails. Then I changed my next step after the redirect to capture the page to find out what the β€œplayer” sees. When I open the image, the HTML appears as if I had never been redirected. I know that redirection works because I see traffic in Fiddler that shows that the tunnel is being installed on port 443.

I searched for SO, google and the Google group for Casper and can't find much about redirecting from HTTP to HTTPS, is it Casper / Phantom able to automate a workflow like this, or should I look at something like Selena?

+6
source share
1 answer

Redirection works out of the box in PhantomJS 1.9.8. If you are not sure, you can debug using:

page.onResourceRequested = function(request) { console.log('Request ' + JSON.stringify(request, undefined, 4)); }; page.onResourceReceived = function(response) { console.log('Response ' + JSON.stringify(response, undefined, 4)); }; 

You should see sth in your first answer as:

 "redirectURL": "https//extranet.somecompany.com", 
0
source

All Articles