38
return this.remote
.get(require.toUrl(url))
.elementById('new-todo')
.clickElement()
.keys('Task 1')
.keys("\n")
.keys('Task 2')
.keys("\n")
.keys('Task 3')
.getAttribute('value')
.then(function(val) {
assert.ok(val.indexOf('Task 3') > -1);
})
scenario "Signing in with correct credentials" do
page.visit "/sessions/new"
page.fill_in "email", :with => "
[email protected]"
page.fill_in "password", :with => "qwerty"
page.click_button "Login"
page.should have_content("Welcome,
[email protected]!")
end
Intern
Capybara
Here are small code excerpts from standard example tests written with the two tools I presented
earlier.
The goal is not that you look at them in details. If you want to try them, you will do so on your
own.
What I want you to note now is the global flow, what the code says.
It's all about visiting an URL, walking the DOM to select an element, sending clicks and keystroke
events, getting HTML attributes…