From 5ff68cdfb9dfd878ed2e3332bf0ca19005fead1c Mon Sep 17 00:00:00 2001 From: Dylan Lacey Date: Mon, 4 Feb 2013 19:26:42 -0800 Subject: [PATCH] Changed from sauce-labs/appium to appium/appium --- sample-code/examples/ruby/simple_test.rb | 31 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/sample-code/examples/ruby/simple_test.rb b/sample-code/examples/ruby/simple_test.rb index 5388845e3..c97da3aa5 100644 --- a/sample-code/examples/ruby/simple_test.rb +++ b/sample-code/examples/ruby/simple_test.rb @@ -1,8 +1,24 @@ -# RSpec is delightful, but the gist should be the same for test::unit +# This documentation is intended to show you how to get started with a +# simple Selenium-Webdriver test. This test is written with RSpec but the +# webdriver commands (everything called after @driver) will work with any +# testing framework. # -# Before this test will work, you may need to do: -# -# gem install rspec webdriver +# We're assuming you've got rvm installed, but if not, from a terminal +# run the following line (removing the ""'s): +# +# "\curl -L https://get.rvm.io | bash -s stable --ruby" +# +# Then, change to the example directory: +# "cd appium-location/sample-code/examples/ruby" +# +# and install the required gems with bundler by doing: +# "bundle install" +# +# To actually run the tests, make sure appium is running in another terminal +# window, then from the same window you used for the above commands, type +# "rspec simple_test.rb" +# +# It will take a while, but once it's done you should get nothing but a line telling you "1 example, 0 failures". require 'rspec' require 'selenium-webdriver' @@ -35,15 +51,16 @@ describe "Computation" do it "should add two numbers" do values = [rand(10), rand(10)] expected_sum = values.reduce(&:+) - elements = @driver.find_elements(:name, 'textField') + elements = @driver.find_elements(:tag_name, 'textField') elements.each_with_index do |element, index| element.send_keys values[index] end - button = @driver.find_elements(:name, 'button')[0] + button = @driver.find_element(:tag_name, 'button') button.click - @driver.find_elements(:name, 'staticText')[0].should eq expected_sum + actual_sum = @driver.find_elements(:tag_name, 'staticText')[0].text + actual_sum.should eq(expected_sum.to_s) end end