Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2445091
  • 博文数量: 328
  • 博客积分: 4302
  • 博客等级: 上校
  • 技术积分: 5486
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-01 11:14
个人简介

悲剧,绝对的悲剧,悲剧中的悲剧。

文章分类

全部博文(328)

文章存档

2017年(6)

2016年(18)

2015年(28)

2014年(73)

2013年(62)

2012年(58)

2011年(55)

2010年(28)

分类: iOS平台

2016-02-02 07:04:49

This tutorial covers automating native iOS apps in Ruby and Java. To select the active language, click Ruby or Java on the left hand side. Code samples and content will change based on the selected language.


Getting started with appium


Introduction
Appium enables iOS and Android automation using Selenium WebDriver. The same WebDriver bindings can be used across web and mobile.

Open Source
Apache 2.0 License
Cross Platform
Test Android on OS X, Windows, Linux
Test iOS on OS X
Native, Hybrid, Mobile Web
Any language. Any framework.
No app changes or source code access required.
In this chapter, we’ll be preparing to automate a native iOS application.


Install Overview
This document is written for OS X 10.9.2 or better.


Tool Description
OS X The mac operating system
Xcode Apple’s integrated development environment
rvm The ruby version manager. Helps install ruby
gem The rubygems command. A package manager for Ruby
Java A programming language and software development kit
bundler Enables managing gem dependencies
brew Helps install software on Macs
npm Node’s package manager
grunt A command line task runner for node.js
ant A java build system
maven A java build system with improved dependency management
Note that Appium.app provides a ready to run version of appium. If you’re using Appium.app then there’s no need to run from source unless you want to use the latest and greatest.


Install Xcode 5.1 from the App Store.


Install the command line build tools within Xcode. (Xcode -> Preferences -> Downloads). Alternatively, download them directly from Apple.


Install Java 7.
Install Ruby
Install the latest stable release of Ruby.
\curl -sSL | bash -s stable
rvm install ruby


Make sure RVM is using the correct Ruby by default
rvm list
rvm --default use 2.1.1


If you have an old ruby/rvm, you can upgrade with
rvm get head
rvm autolibs homebrew
rvm install ruby


Check that it’s installed properly by printing the ruby version.
ruby --version


Update RubyGems and Bundler.
gem update --system
gem install --no-rdoc --no-ri bundler
gem update
gem cleanup


Check that RubyGems is >= 2.1.5
gem --version


Install appium_console gem.
gem uninstall -aIx appium_lib
gem uninstall -aIx appium_console
gem install --no-rdoc --no-ri appium_console


Install flaky gem.
gem uninstall -aIx flaky
gem install --no-rdoc --no-ri flaky


Install brew
ruby -e "$(curl -fsSL )"


Install nodejs using brew.
brew update
brew upgrade node
brew install node


Node should be v0.10.26 or better. Don’t use the big green install button on nodejs.org or all npm commands will require sudo.
node --version
npm --version


Install grunt.
npm install -g grunt grunt-cli


Run the version command from the appium folder. If you’re not in that folder, the grunt version will not display.
grunt --version
grunt-cli v0.1.13
grunt v0.4.2


Install ant if it’s not already installed.
Install maven 3.1.1 or better if it’s not already installed. Old maven will not work.
ant -version
mvn -version


Clone appium
git clone git://github.com/appium/appium.git


Run reset.sh. When running reset.sh, make sure to be on Xcode 5.0.2 for best results. You may have problems if you reset on Xcode 4.6.3 and then switch to a newer Xcode.
cd appium; ./reset.sh


If you see config errors, try cleaning git. git clean -dfx; git reset --hard


You can also reset by platform. ./reset.sh --ios


Authorize for testing. Must run reset.sh as mentioned above before running the grunt task. If you’re only testing Android, this can be skipped.
sudo `which grunt`; authorize


Start appium.
$ node .


Bash Profile
You may have to add grunt as well /usr/local/share/npm/bin/grunt
$ nano ~/.bash_profile
PATH=$PATH:/Applications/apache-ant-1.8.4/bin
PATH=$PATH:/usr/local/share/npm/bin/
export JAVA_HOME="`/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home`"


export PATH


Troubleshooting
If install fails, keep trying to install a few times.
When using Appium.app make sure to set Appium -> Preferences… -> Check “Use External Appium Package” and set it to the path of Appium cloned from GitHub.


Fix permission errors. npm shouldn’t require sudo.


brew uninstall node
brew install node
rm -rf ./node_modules
rm -rf "/Users/`whoami`/.npm"
rm -rf /usr/local/lib/node_modules/
./reset.sh --ios
./reset.sh --android


Helper bash methods
SSL Issues
Unable to download data from - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed


Fix SSL issues with:
rvm osx-ssl-certs update all
rvm osx-ssl-certs status all


Maven on OS X 10.9
brew update
brew install maven


Corrupt ruby gems
If you see:


invalid gem: package is corrupt, exception while verifying: undefined method


Then run rm -rf ~/.rvm and reinstall RVM.


Ruby IDE
I recommend the RubyMine IDE. For professional work, features such as auto completion, jump to definition, and refactoring are valuable.


If you have a preferred editor already, then feel free to continue using it.


Java IDE
Java has a number of popular editors. For this module, we’ll be using IntelliJ IDEA Community Edition, an open source IDE by JetBrains. The software is available for free download at this link.


If you already have a preferred editor, feel free to continue using it. The sample projects use Maven and work with Eclipse, NetBeans, and IntelliJ.


Helpful Links
Link Summary
npm The main registry for npm packages. Appium is published here.
rubygems The main registry for Ruby gems. The appium ruby bindings are published here.
RVM RVM’s homepage. Extensive documentation is available.
Ruby The Ruby language homepage. Useful for keeping up to date with Ruby releases.
Summary
We learned about the appium project and how it’s useful for automating mobile applications. Then we installed all the necessary software to begin automation. Finally, helpful links were reviewed.

repost from 
阅读(1799) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~