Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I figured it out. Basically it's an async issue. You can't just submit and expect to render the subsequent page immediately. You have to wait until the onLoad event for the next page is triggered. My code is below:</p> <pre class="lang-js prettyprint-override"><code>var page = new WebPage(), 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"); }; var steps = [ function() { //Load Login Page page.open("https://website.com/theformpage/"); }, function() { //Enter Credentials page.evaluate(function() { var arr = document.getElementsByClassName("login-form"); var i; for (i=0; i &lt; arr.length; i++) { if (arr[i].getAttribute('method') == "POST") { arr[i].elements["email"].value="mylogin"; arr[i].elements["password"].value="mypassword"; return; } } }); }, function() { //Login page.evaluate(function() { var arr = document.getElementsByClassName("login-form"); var i; for (i=0; i &lt; arr.length; i++) { if (arr[i].getAttribute('method') == "POST") { arr[i].submit(); return; } } }); }, function() { // Output content of page to stdout after form has been submitted page.evaluate(function() { console.log(document.querySelectorAll('html')[0].outerHTML); }); } ]; interval = setInterval(function() { if (!loadInProgress &amp;&amp; typeof steps[testindex] == "function") { console.log("step " + (testindex + 1)); steps[testindex](); testindex++; } if (typeof steps[testindex] != "function") { console.log("test complete!"); phantom.exit(); } }, 50); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload