ruby appium 準備環境

來源:互聯網
上載者:User

標籤:des   android   style   blog   http   io   color   os   ar   

最近打算學習下ruby,也順帶深入嘗試下appium

於是配置環境

 

os x內建了ruby,所以安裝就省了

不過還要安裝下Bundler,在我大天朝,gem install bundle有可能報找不到bundle的錯誤,區域網路嘛,多試幾次。不行就上個代理

 

Install Bundler:  gem install bundle

Install Gems:  bundle update

這樣就算準備好了

跑一下官網給的例子程式

目前appium貌似最高只支援7.1

昨天手賤升級了下xcode到6.0,找了下貌似沒發現什麼解決辦法。

不得不又還原到低版本

ruby simple_test.rb成功啟動模擬器,運行了TestApp。這樣ios環境方面算是準備好了

# GETTING STARTED# -----------------# This documentation is intended to show you how to get started with a# simple Appium & appium_lib test.  This example is written without a specific# testing framework in mind;  You can use appium_lib on any framework you like.## INSTALLING RVM# --------------# If you don‘t have rvm installed, run the following terminal command## \curl -L https://get.rvm.io | bash -s stable --ruby## INSTALLING GEMS# ---------------# Then, change to the example directory:#   cd appium-location/sample-code/examples/ruby## and install the required gems with bundler by doing:#   bundle install## RUNNING THE TESTS# -----------------# To run the tests, make sure appium is running in another terminal# window, then from the same window you used for the above commands, type## bundle exec ruby simple_test.rb## It will take a while, but once it‘s done you should get nothing but a line# telling you "Tests Succeeded";  You‘ll see the iOS Simulator cranking away# doing actions while we‘re running.require ‘rubygems‘require ‘appium_lib‘APP_PATH = ‘/Users/zhangminjie/Documents/AppiumTest2/apps/TestApp/build/Release-iphonesimulator/TestApp.app‘desired_caps = {  caps:       {    platformName:  ‘iOS‘,    versionNumber: ‘7.1‘,    deviceName:    ‘iPhone Simulator‘,    app:           APP_PATH,  },  appium_lib: {    sauce_username:   nil, # don‘t run on Sauce    sauce_access_key: nil  }}# Start the driverAppium::Driver.new(desired_caps).start_drivermodule 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     = 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)    # Alerts are visible    button(‘show alert‘).click    find_element :class_name, ‘UIAAlert‘ # Elements can be found by :class_name    # wait for alert to show    wait { text ‘this alert is so cool‘ }    # Or by find    find(‘Cancel‘).click    # Waits until alert doesn‘t exist    wait_true { !exists { tag(‘UIAAlert‘) } }    # Alerts can be switched into    button(‘show alert‘).click # Get a button by its text    alert         = driver.switch_to.alert # Get the text of the current alert, using    # the Selenium::WebDriver directly    alerting_text = alert.text    raise Exception unless alerting_text.include? ‘Cool title‘    alert_accept # Accept the current alert    # Window Size is easy to get    sizes = window_size    raise Exception unless sizes.height == 568    raise Exception unless sizes.width == 320    # Quit when you‘re done!    driver_quit    puts ‘Tests Succeeded!‘  endend

 

Android上面比較簡單,裝了Android模擬器,啟動Android模擬器

require ‘appium_lib‘caps   = { caps:       { platformName: ‘Android‘, appActivity: ‘.ui.ConversationList‘, appPackage: ‘com.android.mms‘,deviceName:‘Android Emulator‘},           appium_lib: { sauce_username: nil, sauce_access_key: nil } }driver = Appium::Driver.new(caps).start_driver

 

成功啟動簡訊應用,算是拉通了

 

對於我這種英文渣 中文的資料很重要

http://appium.io/slate/cn/v1.2.0/?ruby#appium 

http://www.cnblogs.com/nbkhic/p/3804637.html

ruby appium 準備環境

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.