Once you have loaded a page containing the user subscription form, you can fill the form and submit it back to the server. For this, we will use a new test case:
it("should submit", function(done) { Browser.visit("http://localhost:3000/users/new", function(err, browser) { if (err) throw err; browser .fill('E-mail', '[email protected]') .fill('Password', 'mypassword') .pressButton('Submit', function(err) { if (err) throw err; assert.equal(browser.text('h1'), 'Thank you!'); assert(browser.query('a[href="/session/new"]'), 'has login link'); done(); }); }); });
Here we're revisiting the user creation form, and once the form has loaded, we're filling in the e-mail and password fills by using the browser.fill(<field>, <value>)
method. In this form, browser.fill()
accepts several types of arguments as a field identifier. Here we're using the label text that precedes the field. If you view the source...