Skip to content

Instantly share code, notes, and snippets.

@nnarhinen
Created October 11, 2011 10:54
Show Gist options
  • Save nnarhinen/1277810 to your computer and use it in GitHub Desktop.
Save nnarhinen/1277810 to your computer and use it in GitHub Desktop.
Feature: Login
In order to be able to log in securely
A user wants to make sure he is required to give correct username and password
Scenario: No credentials given
Given I am on the front page
When I submit "form-login"
Then I should see "Käyttäjätunnus tai salasana puuttuu"
Scenario: Wrong credentials
Given I am on the front page
When I type "foobar@foobar.tld" as "fe-loginemail"
And I type "foobar1234" as "fe-loginpassword"
And I submit "form-login"
Then I should see "Virheellinen käyttäjätunnus tai salasana"
require "selenium-webdriver"
require "rspec/expectations"
driver = Selenium::WebDriver.for :chrome
at_exit do
driver.quit
end
Given /^I am on the front page$/ do
driver.navigate.to "http://localhost/~nnarhinen/foo/bar/src/pub/"
end
Then /^I should see "([^"]*)"$/ do |arg1|
driver.find_element(:tag_name => 'body').text.should =~ /#{arg1}/m
end
When /^I submit "([^"]*)"$/ do |form_id|
driver.find_element(:id => "#{form_id}").submit
end
When /^I type "([^"]*)" as "([^"]*)"$/ do |value, input_id|
driver.find_element(:id => "#{input_id}").send_keys "#{value}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment