Skip to content
This repository has been archived by the owner on Mar 23, 2020. It is now read-only.

Added Cucumber web for iOS to run through appium on simulator #42

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# 1. Start Appium in a terminal window
# 2. From another terminal window, open the cucumber example directory at
# appium/sample-code/examples/ruby/cucumber_ios/
# appium/sample-code/examples/ruby/cucumber_web/
# 3. type 'cucumber' and hit enter
# 4. If you see '1 scenario (1 passed)' and some other stuff, SUCCESS! The
# test passed. If you didn't, BOOOO, that's not right. Make sure you've
Expand All @@ -35,13 +35,13 @@
# https://github.com/cucumber/cucumber/wiki/Feature-Introduction


Feature: Addition
In order to revolutionize maths teaching
As an iOS developer
I want to be able to sum two numbers
Feature:
In order to explore mobile web
As an mobile web QA developer
I want to check elements in guniapig

Scenario: Add two numbers
Given I have entered 4 into field 1 of the calculator
And I have entered 7 into field 2 of the calculator
When I press button 1
Then the result should be displayed as 11
Scenario: Enter email and comments
Given I have entered sandbox.example@guniapig.com into Email field
And I have entered 'Test comments' into Comments field
When I click on i am a link
Then I am on other page
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# These are the 'step definitions' which Cucumber uses to implement features.
#
# Each step starts with a regular expression matching the step you write in
# your feature description. Any variables are parsed out and passed to the
# step block.
#
# The instructions in the step are then executed with those variables.
#
# The '$driver' object is the appium_lib driver, set up in the cucumber/support/env.rb
# file, which is a convenient place to put it as we're likely to use it often.
# For more on step definitions, check out the documentation at
# https://github.com/cucumber/cucumber/wiki/Step-Definitions
#
# For more on rspec assertions, check out
# https://www.relishapp.com/rspec/rspec-expectations/docs
Given(/^I have entered ([^"]*) into Email field$/) do |value|
@driver.find_element(id:'fbemail').send_keys(value)
Selenium::WebDriver::Wait.new(timeout:2,message:'Text not entered into email').until { @driver.find_element(id:'fbemail').attribute('value').eql?value }
end

And(/^I have entered ([^"]*) into Comments field$/) do |value|
@driver.find_element(id:'comments').send_keys(value)
Selenium::WebDriver::Wait.new(timeout:2,message:'Text not entered into comments').until { @driver.find_element(id:'comments').attribute('value').eql?value }
end

When(/^I click on ([^"]*)$/) do |va|
element = @driver.find_element(id:va)
raise 'No link found' unless element.displayed?
element.click
Selenium::WebDriver::Wait.new.until { @driver.title.start_with?'I am another page title' }
end

Then(/^I am on other page$/) do
element = @driver.find_element(id:'i_am_an_id')
raise "Doesn't open next page" unless element.text.eql?'I am another div'
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should end in a newline for git

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[caps]
platformName = "ios"
deviceName = "iPhone Simulator"
platformVersion = "7.1"
browserName = "Safari"
custom_url = "http://localhost:4723/wd/hub"

[appium_lib]
sauce_username = false
sauce_access_key = false
30 changes: 30 additions & 0 deletions sample-code/examples/ruby/cucumber_ios_web/features/support/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file provides setup and common functionality across all features. It's
# included first before every test run, and the methods provided here can be
# used in any of the step definitions used in a test. This is a great place to
# put shared data like the location of your app, the capabilities you want to
# test with, and the setup of selenium.

require 'rspec/expectations'
require 'appium_lib'
require 'cucumber/ast'
require 'selenium-webdriver'

# Create a custom World class so we don't pollute `Object` with Appium methods
class AppiumWorld
end

# Load the desired configuration from appium.txt, create a driver then
# Add the methods to the world
caps = Appium.load_appium_txt file: File.expand_path('./', __FILE__), verbose: true
Appium::Driver.new(caps)

World do
AppiumWorld.new
end

Before {
@driver = $driver.start_driver
@driver.get('http://saucelabs.com/test/guinea-pig')
Selenium::WebDriver::Wait.new(timeout:3).until { @driver.title.start_with?'I am a page title' }
}
After { $driver.driver_quit }