Files
appium/sample-code/examples/ruby/cucumber/features/step_definitions/steps.rb
Dylan Lacey 633c2ed81e Update Ruby sample code.
Change from tag_name to class_name for u\_i\_catalog, simple\_test,
cucumber tests.

Changed to iOS 7.1 in u\_i\_catalog, simple\_test, cucumber tests.

Changed `capabilities` to `desired_caps` to avoid some weirdo
collisions.

Remove Debugging output from Cucumber.

Add example of send\_keys as an action chain for u\_i\_catalog.
2014-04-01 01:46:27 -07:00

35 lines
1.3 KiB
Ruby

# 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.
#
# In this example, we're using rspec's assertions to test that things are happening, but you can use any ruby code you want in the steps.
#
# The 'selenium' object is our webdriver, 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 (\d+) into field (\d+) of the calculator$/ do |value, field|
elements = selenium.find_elements(:class_name, "UIATextField")
elements[field.to_i - 1].send_keys value
end
And /^I press button (\d+)$/ do |button_index|
button = selenium.find_elements(:class_name, "UIAButton")[button_index.to_i - 1 ]
button.click
end
Then /^the result should be displayed as (\d+)$/ do |expected|
result = selenium.find_element(:class_name, "UIAStaticText")
result.attribute("value").should eq expected
end