Skip to content

Instantly share code, notes, and snippets.

@Jonahss
Created April 20, 2015 19:02
Show Gist options
  • Save Jonahss/f2216d1dbc892aa2d202 to your computer and use it in GitHub Desktop.
Save Jonahss/f2216d1dbc892aa2d202 to your computer and use it in GitHub Desktop.
simpletest.rb
require 'rubygems'
require 'appium_lib'
APP_PATH = '/Users/jonahss/Workspace/appium/sample-code/apps/TestApp/build/Release-iphonesimulator/TestApp.app'
desired_caps = {
'platformName' => 'ios',
'platformVersion' => '7.1',
'deviceName' => 'iPhone Simulator',
'app' => APP_PATH
}
# Start the driver
Appium::Driver.new(caps: desired_caps).start_driver
module Calculator
module IOS
# Add all the Appium library methods to Test to make
# calling them look nicer.
Appium.promote_singleton_appium_methods Calculator
# Add two numbers
values = [rand(10), rand(10)]
expected_sum = values.reduce(&:+)
# Find every textfield.
elements = find_elements :uiautomation, '.textFields();'
elements.each_with_index do |element, index|
element.type values[index]
end
# Click the first button
button(1).click
# Get the first static text field, then get its text
actual_sum = first_text.text
raise unless actual_sum == (expected_sum.to_s)
# Quit when you're done!
driver_quit
puts 'Tests Succeeded!'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment