Last active
August 29, 2015 14:00
-
-
Save gunesmes/11395396 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'capybara' | |
require 'capybara-webkit' | |
require 'capybara/dsl' | |
require 'capybara/rspec' | |
require 'capybara/poltergeist' | |
Capybara.run_server = false | |
Capybara.app_host = 'http://www.amazon.com' | |
Capybara.default_driver = :selenium | |
#Capybara.default_driver = :webkit | |
Capybara.javascript_driver = :webkit | |
Capybara.default_selector = :css | |
Capybara.default_selector = :xpath | |
Capybara.default_wait_time = 2 #default wait time for ajax | |
Capybara.ignore_hidden_elements = false #ignore hidden elements when testing, make helpful when you hide or show elements using javascript | |
module Helpers | |
def without_resynchronize | |
page.driver.options[:resynchronize] = false | |
yield | |
page.driver.options[:resynchronize] = true | |
end | |
end | |
Capybara.register_driver :poltergeist do |app| | |
options = { | |
# you can set option here | |
# :js_errors => false , | |
# :timeout => 120, | |
# :debug => true, | |
# :inspector => true, | |
# :window_size => [1280, 1024], | |
# :logger => false, | |
# :inspector => false, | |
# :visible => false, | |
} | |
Capybara::Poltergeist::Driver.new(app, options) | |
end | |
Capybara.register_driver :chrome do |app| | |
Capybara::Selenium::Driver.new(app, :browser => :chrome) | |
end | |
World(Capybara::DSL, Helpers) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: As a customer | |
In order to buy something | |
From the amazon.com | |
I want to login the page | |
Scenario: Member logins the page | |
Given I am on home page of Amazon | |
When I click "Hello. Sign in" button | |
And I sign in with "[email protected]" and "wrong.password" | |
Then Page should have content "There was a problem with your request" | |
When I sign in with "[email protected]" and "correct.password" | |
Then Page should have content "Hello, mesut" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given(/^I am on home page of Amazon$/) do | |
visit "/" | |
end | |
When (/^I click "(.*?)" button$/) do |button| | |
click_link(button) | |
end | |
When(/^I sign in with "(.*?)" and "(.*?)"$/) do |username, password| | |
fill_in "ap_email", :with => username | |
fill_in "ap_password", :with => password | |
click_on("signInSubmit-input") | |
end | |
Then(/^Page should have content "(.*?)"$/) do |text| | |
page.should have_content text | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment