Created
April 20, 2015 19:02
-
-
Save Jonahss/f2216d1dbc892aa2d202 to your computer and use it in GitHub Desktop.
simpletest.rb
This file contains 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 '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