Filling a magazine in a form with zombies in node.js

Evening! I am trying to login to a site with zombie.js, but it seems like I cannot get it to work. Oh, and the site is in Finnish, but it's not very difficult to understand, two text fields and a button. First for the username, the second for the password and the button is the login button.

At the moment, my login code is as follows:

var Browser = require("zombie");
browser = new Browser();
browser.visit("https://www.nordnet.fi/mux/login/startFI.html?cmpi=start-loggain",
    function () {
        // Here I check the title of the page I'm on.
        console.log(browser.text("title"));
        // Here I fill the needed information.
        browser.document.getElementById("input1").value ="MYUSERNAME";
        browser.document.getElementById("pContent").value ="MYPASSWORD";
        // And here it fails. I try to submit the form in question.
        browser.document.getElementById("loginForm").submit();
        setTimeout(function () {
            // This is here to check that we've submitted the info and have been
            // redirected to a new website.
            console.log(browser.text("title"));
        }, 2000);
});

Now I know that I might have had to use my own method of “filling in” zombies, but I tried it with no luck, so I tried something new.

All I get is an error:

Y:\IMC\Development\Web\node_modules\zombie\lib\zombie\forms.js:72
  return history._submit(_this.getAttribute("action"), _this.getAttribute(
                 ^
TypeError: Cannot call method '_submit' of undefined

Now, if I register this browser.document.getElementById("loginForm"), he clearly finds the form, but, alas, for some reason he does not like it.

"" , - . , , , , , <span>. , "click" .

, , , , . ä /344 :

throw new Error("No BUTTON '" + selector + "'");
        ^
Error: No BUTTON 'Kirjaudu sisään'

, , , .

, - , - , , .

, - , , YQL ? , 15 , , , .

+5
1

, . , submit ( .submit()).

var Browser = require("zombie");
var assert = require("assert");

browser = new Browser()
browser.visit("http://duckduckgo.com/", function () {
    // fill search query field with value "zombie"
    browser.fill('input[name=q]', 'mouse');
    // **how** you find a form element is irrelevant - you can use id, selector, anything you want
    // in this case it was easiest to just use built in forms collection - fire submit on element found
    browser.document.forms[0].submit();
    // wait for new page to be loaded then fire callback function
    browser.wait().then(function() {
        // just dump some debug data to see if we're on the right page
        console.log(browser.dump());
    })
});

, browser.wait().then(...) , browser - (, visit). : , , - , , .


Edit: , , ( " " ). JS, ( , , , script ). , script :

var Browser = require("zombie");
var assert = require("assert");

browser = new Browser()
browser.visit("https://www.nordnet.fi/mux/login/startFI.html?cmpi=start-loggain", function () {
    // fill in login field
    browser.fill('#input1', 'zombie');
    // fill in password field
    browser.fill('#pContent', 'commingyourway');
    // submit the form
    browser.document.forms[0].submit();
    // wait for new page to be loaded then fire callback function
    browser.wait().then(function() {
        console.log('Form submitted ok!');
        // the resulting page will be displayed in your default browser
        browser.viewInBrowser();
    })
});

: , ( ):

  • google.com - , . ? , Google , (, ) .
  • bing.com - , Google - . ? , , google.
  • paulirish.com - zombie script, (- ActiveX script).
  • perfectionkills.com - , , Paul Irish, - JavaScript.

: ...:)

+7

All Articles