Phantom.js .NET authentication -


what common problems when trying authenticate phantom.js against asp.net site?

here specific issue; able navigate asp.net site , fill in login form appropriately, verify rendering simple test.png file. point works expected.

once submit form (either form.submit() or element.click();), page reloads not redirected authenticated side of site. it's same page if authentication failed. difference, though, new rendered page has password removed password field.

i know credentials correct, can log in browser.

i using following test script received post , made minor changes. can please me or point me in right direction?

var page = require('webpage').create(),     testindex = 0,     loadinprogress = false;  page.onconsolemessage = function(msg) {   console.log(msg); };  page.onloadstarted = function() {   loadinprogress = true;   console.log("load started"); };  page.onloadfinished = function() {   loadinprogress = false;   console.log("load finished"); };  /* page.onnavigationrequested = function(url, type, willnavigate, main) {   console.log('trying navigate to: ' + url);   console.log('caused by: ' + type);   console.log('will navigate: ' + willnavigate);   console.log('sent page\'s main frame: ' + main); }; */   console.log('the default user agent ' + page.settings.useragent); //changing user agent ie in case! page.settings.useragent = 'mozilla/5.0 (compatible; msie 10.0; windows nt 6.1; trident/4.0; infopath.2; sv1; .net clr 2.0.50727; wow64)'; console.log('the new user agent ' + page.settings.useragent);  /*   steps array represents finite set of steps in order perform unit test */  var steps = [   function() {     //load login page     page.open("https://www.aspxpage/signin.aspx");   },   function() {     //enter credentials     page.evaluate(function() {        //fill form correct credintals       //var loginform = document.getelementbyid("aspnetform");       document.queryselector('input[name=id]').value = 'blah';       document.queryselector('input[name=user]').value = 'blah';       document.queryselector('input[name=password]').value = 'blah';        });   },    function() {     //login     page.evaluate(function() {     //submit form      //form submit      //1.         //var loginform = document.getelementbyid("formid");         //loginform.submit();      //2.     //button click         var button = document.queryselector('input[id=buttonid]');     button.click();         //console.log(button);       });   },    function() {     // output content of page stdout after form has been submitted     page.evaluate(function() {       //console.log(document.queryselectorall('html')[0].outerhtml);     });      //render test image see if login passed     page.render('test.png');    } ];   interval = setinterval(function() {   if (!loadinprogress && typeof steps[testindex] === "function") {     console.log("step " + (testindex + 1));     steps[testindex]();     testindex++;   }   if (typeof steps[testindex] !== "function") {     console.log("test complete!");     phantom.exit();   } }, 50);  

i think 50 ms not enough time can post-login page. should chain last call don't interfere login process. and, solidity/sanity, suggest don't render between password fill , button click (that might trigger refresh of page , erase password text box). keep rendering code debugging purposes, time being - not testing whole chain of calls.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -