Cucumber With Ruby & Capybara

Feature File:


Feature: Automate Flipkart website

Scenario: Login for Flipkart
  Given I open browser and navigate to flipkart website
  Then I click on login Link
 Then I enter Email Id
 Then  I enter Password
  Then I click on Login Button
  Then I mouse over the user
  Then I click on Logout


Step Definition File

Given(/^I open browser and navigate to flipkart website$/) do
  visit 'http://www.flipkart.com'
end

Then(/^I click on login Link$/) do
    find(:xpath, "//a[@href='https://www.flipkart.com/account/login?from=header']").click
end

Then(/^I enter Email Id$/) do 
    fill_in 'login_email_id', :with => 'xxx@gmail.com'
end

Then(/^I enter Password$/) do
  fill_in 'login_password', :with => 'password'
end

Then(/^I click on Login Button$/) do
  click_button 'Login'
  sleep(10)
end

Then(/^I mouse over the user$/) do
 element=find(:xpath,"//a[@href='https://www.flipkart.com/account/']")
  page.execute_script('$("#element").trigger("mousehover")')
end

Then(/^I click on Logout$/) do
 @b.link(:xpath,".//*[text()='Hi TestUser.... !']/following::*[20]").when_present.click
end






Comments

Popular posts from this blog

Testing Webservice with SoapUI Having Windows Authentication

Data Driven Testing Using Selenium -WebDriver in Python

How to Re-run Failed Scenarios in Cucumber