web_console 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +2 -0
- data/LICENSE-2.0.txt +202 -0
- data/Rakefile +155 -0
- data/bin/rubyweb +51 -0
- data/ios_v_android.md +58 -0
- data/lib/start.rb +93 -0
- data/lib/web_console.rb +57 -0
- data/lib/web_console/version.rb +7 -0
- data/osx.md +274 -0
- data/osx_install.rake +135 -0
- data/readme.md +86 -0
- data/release_notes.md +352 -0
- data/web_console.gemspec +34 -0
- metadata +130 -0
data/lib/start.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'spec' # https://github.com/bootstraponline/spec
|
4
|
+
require 'selenium-webdriver'
|
5
|
+
require 'page-object' # https://github.com/cheezy/page-object
|
6
|
+
|
7
|
+
$driver = Selenium::WebDriver.for :firefox
|
8
|
+
$driver.manage.timeouts.implicit_wait = 30 # seconds
|
9
|
+
|
10
|
+
# Load minitest
|
11
|
+
begin
|
12
|
+
require 'minitest'
|
13
|
+
require 'minitest/spec'
|
14
|
+
# set current_spec. fixes:
|
15
|
+
# NoMethodError: undefined method `assert_equal' for nil:NilClass
|
16
|
+
Minitest::Spec.new 'pry'
|
17
|
+
rescue
|
18
|
+
end
|
19
|
+
|
20
|
+
module Pages; end
|
21
|
+
|
22
|
+
# Promote methods to top level for Pry
|
23
|
+
# Pages module is hard coded.
|
24
|
+
def promote_page_object_methods
|
25
|
+
::Pages.constants.each do |class_name|
|
26
|
+
puts "Promoting class_name as method #{class_name.to_s.downcase}"
|
27
|
+
Kernel.send(:define_method, class_name.to_s.downcase) do
|
28
|
+
Pages.const_get(class_name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def reload
|
34
|
+
Pry.send :_reload
|
35
|
+
promote_page_object_methods
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_wait seconds
|
40
|
+
$driver.manage.timeouts.implicit_wait = seconds
|
41
|
+
end
|
42
|
+
|
43
|
+
# -- helper methods
|
44
|
+
module Kernel
|
45
|
+
def id id
|
46
|
+
$driver.find_elements(:id, id).detect { |ele| ele.displayed? }
|
47
|
+
end
|
48
|
+
|
49
|
+
def css css
|
50
|
+
$driver.find_elements(:css, css).detect { |ele| ele.displayed? }
|
51
|
+
end
|
52
|
+
|
53
|
+
def xpath xpath
|
54
|
+
$driver.find_elements(:xpath, xpath).detect { |ele| ele.displayed? }
|
55
|
+
end
|
56
|
+
|
57
|
+
def link text
|
58
|
+
xpath("//a[text()='#{text}']")
|
59
|
+
end
|
60
|
+
|
61
|
+
def input input
|
62
|
+
xpath("//input[@value='#{input}']")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
# --
|
66
|
+
|
67
|
+
def x
|
68
|
+
$driver.quit if $driver
|
69
|
+
exit
|
70
|
+
end
|
71
|
+
|
72
|
+
# Ensure page objects are loaded
|
73
|
+
reload
|
74
|
+
# Default wait to 0
|
75
|
+
set_wait 0
|
76
|
+
|
77
|
+
# Don't print page objects
|
78
|
+
# default print code from https://github.com/pry/pry/blob/master/lib/pry.rb
|
79
|
+
# pry-0.9.12.3
|
80
|
+
Pry.config.print = proc do |output, value|
|
81
|
+
unless value.nil? || value.inspect.to_s.include?('SeleniumWebDriver::PageObject')
|
82
|
+
Pry::output_with_default_format(output, value, :hashrocket => true)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# loop through all pages and output the methods
|
87
|
+
def page
|
88
|
+
Pages.constants.each do |page|
|
89
|
+
methods = Pages.const_get(page).singleton_methods
|
90
|
+
methods.each { |m| puts "#{page.to_s.downcase}.#{m}" }
|
91
|
+
end
|
92
|
+
nil
|
93
|
+
end
|
data/lib/web_console.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
Gem::Specification.class_eval { def self.warn( args ); end }
|
4
|
+
require 'pry'
|
5
|
+
require 'awesome_print'
|
6
|
+
|
7
|
+
module Appium; end unless defined? Appium
|
8
|
+
|
9
|
+
def define_reload paths
|
10
|
+
Pry.send(:define_singleton_method, :_reload) do
|
11
|
+
paths.each do |p|
|
12
|
+
# If a page obj is deleted then load will error.
|
13
|
+
begin
|
14
|
+
load p
|
15
|
+
rescue # LoadError: cannot load such file
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
module Appium::Console
|
23
|
+
AwesomePrint.pry!
|
24
|
+
pwd = Dir.pwd
|
25
|
+
to_require = pwd + '/appium.txt'
|
26
|
+
|
27
|
+
start = File.expand_path '../start.rb', __FILE__
|
28
|
+
cmd = ['-r', start]
|
29
|
+
|
30
|
+
if File.exists?(to_require)
|
31
|
+
to_require = File.read(to_require).split("\n").map do |line|
|
32
|
+
unless File.exists?(line)
|
33
|
+
line = File.join(pwd, line)
|
34
|
+
end
|
35
|
+
|
36
|
+
if File.exists?(line)
|
37
|
+
if File.directory?(line)
|
38
|
+
found = []
|
39
|
+
Dir.glob(File.join(line, '**/*.rb')) { |f| found << File.expand_path(f) }
|
40
|
+
found
|
41
|
+
else
|
42
|
+
File.expand_path line
|
43
|
+
end
|
44
|
+
else
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
end.flatten.compact # remove nested arrays & nils
|
48
|
+
|
49
|
+
define_reload to_require
|
50
|
+
else
|
51
|
+
puts "This folder doesn't contain an appium.txt listing page objects"
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
|
55
|
+
$stdout.puts "pry #{cmd.join(' ')}"
|
56
|
+
Pry::CLI.parse_options cmd
|
57
|
+
end # module Appium::Console
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Define Appium module so version can be required directly.
|
3
|
+
module Appium; end unless defined? Appium
|
4
|
+
module Appium::Console
|
5
|
+
VERSION = '0.5.8' unless defined? ::Appium::Console::VERSION
|
6
|
+
DATE = '2013-12-11' unless defined? ::Appium::Console::DATE
|
7
|
+
end
|
data/osx.md
ADDED
@@ -0,0 +1,274 @@
|
|
1
|
+
### Getting Started
|
2
|
+
|
3
|
+
This document is written for OS X 10.8.4 or better. iOS testing requires OS X. Android testing works on OS X, Windows, and Linux.
|
4
|
+
|
5
|
+
For OS X, there is rake script which will attempt to do most of this for you, with
|
6
|
+
```
|
7
|
+
rake -f osx_install.rake
|
8
|
+
```
|
9
|
+
The rake script will not install Xcode, etc., nor Java, but should take care of everything else.
|
10
|
+
Changes to these instructions might imply changes to that script as well.
|
11
|
+
|
12
|
+
#### Steps to install
|
13
|
+
|
14
|
+
Install `Xcode` 4.6.3 (iOS 6) or 5.0.0 (iOS 7).
|
15
|
+
|
16
|
+
- Xcode 5.0.0 shouldn't be used for iOS 6 as it's flaky.
|
17
|
+
- Xcode 5.0.1 is broken.
|
18
|
+
- Xcode 4.6.3 doesn't support iOS 7.
|
19
|
+
|
20
|
+
After that, install the command line build tools (Xcode -> Preferences -> Downloads).
|
21
|
+
|
22
|
+
If you're testing iOS 6, then install `Xcode 4.6.3` from [Apple](https://developer.apple.com/downloads/index.action).
|
23
|
+
For iOS 7+ make sure to use Xcode 5.
|
24
|
+
|
25
|
+
That done, you'll need to create a symlink for
|
26
|
+
`gcc` to get the ruby build (particularly FFI) to install properly. This isn't required on OS X 10.9.
|
27
|
+
If `/usr/local/bin` is in your path, you can do:
|
28
|
+
```
|
29
|
+
ln -s /usr/bin/gcc /usr/local/bin/gcc-4.2
|
30
|
+
```
|
31
|
+
Otherwise
|
32
|
+
```
|
33
|
+
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
|
34
|
+
```
|
35
|
+
Reinstall Ruby if you didn't set this symlink and have FFI issues.
|
36
|
+
|
37
|
+
- Install Java 7 if there's no Java on the system.
|
38
|
+
- [JDK 7](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
|
39
|
+
|
40
|
+
- Install the latest stable patch release of Ruby 2.0.
|
41
|
+
|
42
|
+
`$ \curl -L https://get.rvm.io | bash -s stable --ruby=2.0.0`
|
43
|
+
|
44
|
+
- Make sure RVM is using the correct Ruby by default
|
45
|
+
|
46
|
+
```
|
47
|
+
$ rvm list
|
48
|
+
$ rvm --default use 2.0.0
|
49
|
+
```
|
50
|
+
|
51
|
+
- If you have an old ruby, you can installing Ruby 2.0 instead
|
52
|
+
|
53
|
+
```
|
54
|
+
$ rvm get head
|
55
|
+
$ rvm autolibs homebrew
|
56
|
+
$ rvm install 2.0.0
|
57
|
+
```
|
58
|
+
|
59
|
+
- Check that it's installed properly by printing the ruby version.
|
60
|
+
|
61
|
+
`$ ruby --version`
|
62
|
+
|
63
|
+
- Update RubyGems and Bundler.
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
gem update --system ;\
|
67
|
+
gem install --no-rdoc --no-ri bundler ;\
|
68
|
+
gem update ;\
|
69
|
+
gem cleanup
|
70
|
+
```
|
71
|
+
|
72
|
+
- Check that RubyGems is >= 2.1.5
|
73
|
+
|
74
|
+
```bash
|
75
|
+
$ gem --version
|
76
|
+
2.1.5
|
77
|
+
```
|
78
|
+
|
79
|
+
- Install appium_console gem.
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
gem uninstall -aIx appium_lib ;\
|
83
|
+
gem uninstall -aIx appium_console ;\
|
84
|
+
gem install --no-rdoc --no-ri appium_console
|
85
|
+
```
|
86
|
+
|
87
|
+
- Install [flaky](https://github.com/appium/flaky) gem.
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
gem uninstall -aIx flaky ;\
|
91
|
+
gem install --no-rdoc --no-ri flaky
|
92
|
+
```
|
93
|
+
|
94
|
+
- Install [brew](http://mxcl.github.io/homebrew/)
|
95
|
+
|
96
|
+
`ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"`
|
97
|
+
|
98
|
+
- Install [nodejs](http://nodejs.org/) using brew.
|
99
|
+
|
100
|
+
```
|
101
|
+
brew update ;\
|
102
|
+
brew upgrade node ;\
|
103
|
+
brew install node
|
104
|
+
```
|
105
|
+
|
106
|
+
- Node should be `v0.10.5` or better.
|
107
|
+
Don't use the big green install button on nodejs.org or all npm commands will require sudo.
|
108
|
+
|
109
|
+
`$ node --version`
|
110
|
+
|
111
|
+
`$ npm --version`
|
112
|
+
|
113
|
+
- Install grunt.
|
114
|
+
|
115
|
+
`npm install -g grunt grunt-cli`
|
116
|
+
|
117
|
+
- Run the version command from the appium folder. If you're not in that folder, the grunt version will not display.
|
118
|
+
|
119
|
+
```bash
|
120
|
+
$ grunt --version
|
121
|
+
grunt-cli v0.1.6
|
122
|
+
grunt v0.4.1
|
123
|
+
```
|
124
|
+
|
125
|
+
- Install [ant](http://ant.apache.org/) if it's not already installed.
|
126
|
+
- Install [maven 3.0.5](http://maven.apache.org/download.cgi) if it's not already installed. Do not use maven 3.1.1.
|
127
|
+
|
128
|
+
```
|
129
|
+
$ ant -version
|
130
|
+
Apache Ant(TM) version 1.8.2 compiled on June 20 2012
|
131
|
+
$ mvn -version
|
132
|
+
Apache Maven 3.0.3 (r1075438; 2011-02-28 12:31:09-0500)
|
133
|
+
```
|
134
|
+
|
135
|
+
- Clone appium
|
136
|
+
|
137
|
+
`$ git clone git://github.com/appium/appium.git`
|
138
|
+
|
139
|
+
- 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.
|
140
|
+
|
141
|
+
`cd appium; ./reset.sh`
|
142
|
+
|
143
|
+
If you see config errors, try cleaning git. `git clean -dfx; git reset --hard`
|
144
|
+
|
145
|
+
You can also reset by platform. `./reset.sh --android`
|
146
|
+
|
147
|
+
If npm is having issues, you may have to disable https. I don't recommend this, however if you must this is how to do so:
|
148
|
+
|
149
|
+
`npm config set registry http://registry.npmjs.org/`
|
150
|
+
|
151
|
+
|
152
|
+
- Authorize for iOS testing. Must run reset.sh as mentioned above before running the grunt task.
|
153
|
+
|
154
|
+
> sudo \`which grunt\` authorize
|
155
|
+
|
156
|
+
- Start appium.
|
157
|
+
|
158
|
+
`node server.js`
|
159
|
+
|
160
|
+
|
161
|
+
#### Bash Profile
|
162
|
+
- Add the Android SDK tools folder to your path so you can run `android`.
|
163
|
+
- Define the `ANDROID_HOME` env var pointing to SDK root. On OSX place it in `~/.bash_profile`
|
164
|
+
- You may have to add grunt as well `/usr/local/share/npm/bin/grunt`
|
165
|
+
|
166
|
+
```
|
167
|
+
# ~/.bash_profile
|
168
|
+
export ANDROID_HOME=$HOME/Downloads/android-sdk-macosx
|
169
|
+
export ANDROID_SDK=$ANDROID_HOME
|
170
|
+
PATH=$PATH:/Applications/apache-ant-1.8.4/bin
|
171
|
+
PATH=$PATH:/usr/local/share/npm/bin/
|
172
|
+
PATH=$PATH:$ANDROID_HOME/build-tools
|
173
|
+
PATH=$PATH:$ANDROID_HOME/platform-tools
|
174
|
+
PATH=$PATH:$ANDROID_HOME/tools
|
175
|
+
export JAVA_HOME="`/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home`"
|
176
|
+
export APP_PATH="/path/to/MyiOS.app"
|
177
|
+
export APK_PATH="/path/to/my.apk"
|
178
|
+
export APP_PACKAGE="com.example.Package"
|
179
|
+
export APP_ACTIVITY="StartActivity"
|
180
|
+
export APP_WAIT_ACTIVITY="SplashActivity"
|
181
|
+
|
182
|
+
export PATH
|
183
|
+
```
|
184
|
+
|
185
|
+
- Run `android` to open the SDK manager.
|
186
|
+
- Install `Intel x86 Emulator Accelerator (HAXM)` under Extras
|
187
|
+
- Install API 18 `SDK Platform`, `Intel x86 Atom System Image`, `Google APIs`
|
188
|
+
If there are any problems viewing or downloading the packages, go to `Packages -> Reload` and try again.
|
189
|
+
|
190
|
+
- Create a new Android virtual device that uses the Intel image. Ensure `Use Host GPU` is checked. Set `VM Heap` to `64`. `32` is too small.
|
191
|
+
|
192
|
+
![](img/avd_settings.png)
|
193
|
+
|
194
|
+
`android avd`
|
195
|
+
|
196
|
+
- Check that `hax is working` If it's not, install hax [directly from Intel](http://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager)
|
197
|
+
|
198
|
+
```bash
|
199
|
+
$ emulator @t18
|
200
|
+
HAX is working and emulator runs in fast virt mode
|
201
|
+
```
|
202
|
+
|
203
|
+
- Launch the emulator with `emulator @t18`
|
204
|
+
|
205
|
+
- After launching the emulator, check that it's listed in adb devices. Run the following commands a few times until it's listed.
|
206
|
+
|
207
|
+
`adb kill-server; adb devices`
|
208
|
+
|
209
|
+
If you see `error: protocol fault (no status)` just keep running the command until the emulator is detected.
|
210
|
+
|
211
|
+
- With both the Android emulator running and the Appium server started, it's time to launch the appium console. Make sure the ENV vars are exported.
|
212
|
+
|
213
|
+
- Echo the values to make sure they're set correctly
|
214
|
+
|
215
|
+
`$ echo $APP_PATH $APP_PACKAGE $APP_ACTIVITY $APP_WAIT_ACTIVITY`
|
216
|
+
|
217
|
+
- Start appium console
|
218
|
+
|
219
|
+
`arc`
|
220
|
+
|
221
|
+
- See [running on OS X](https://github.com/appium/appium/blob/master/docs/running-on-osx.md)
|
222
|
+
|
223
|
+
#### Troubleshooting
|
224
|
+
|
225
|
+
- If install fails, keep trying to install a few times.
|
226
|
+
|
227
|
+
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.
|
228
|
+
|
229
|
+
Fix permission errors. npm shouldn't require sudo.
|
230
|
+
|
231
|
+
```bash
|
232
|
+
brew uninstall node
|
233
|
+
brew install node
|
234
|
+
rm -rf ./node_modules # run from the appium folder
|
235
|
+
rm -rf "/Users/`whoami`/.npm"
|
236
|
+
rm -rf /usr/local/lib/node_modules/
|
237
|
+
./reset.sh --ios
|
238
|
+
./reset.sh --android
|
239
|
+
```
|
240
|
+
|
241
|
+
- [Helper bash methods](https://gist.github.com/bootstraponline/5580587)
|
242
|
+
|
243
|
+
#### SSL Issues
|
244
|
+
|
245
|
+
> Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
|
246
|
+
|
247
|
+
- [Fix SSL issues](http://railsapps.github.io/openssl-certificate-verify-failed.html) with:
|
248
|
+
|
249
|
+
```bash
|
250
|
+
$ rvm osx-ssl-certs update all
|
251
|
+
$ rvm osx-ssl-certs status all
|
252
|
+
```
|
253
|
+
|
254
|
+
#### Maven on OS X 10.9
|
255
|
+
|
256
|
+
```bash
|
257
|
+
$ cd /usr/local
|
258
|
+
$ git reset --hard origin/master
|
259
|
+
|
260
|
+
$ brew update
|
261
|
+
$ brew install maven
|
262
|
+
```
|
263
|
+
|
264
|
+
#### HAXM on OS X 10.9
|
265
|
+
|
266
|
+
Install the [HAXM 10.9 hotfix](http://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-end-user-license-agreement-macos-hotfix
|
267
|
+
).
|
268
|
+
|
269
|
+
#### Restore dev tools on 10.9
|
270
|
+
|
271
|
+
`xcode-select --install`
|
272
|
+
|
273
|
+
|
274
|
+
- [Install specific node version](https://coderwall.com/p/lqphzg)
|
data/osx_install.rake
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
# For OS X, installs all the dependencies for Appium's ruby console, per these instructions:
|
2
|
+
#
|
3
|
+
# https://github.com/appium/ruby_console/blob/master/osx.md
|
4
|
+
#
|
5
|
+
# Changes to this file might imply changes to those instructions as well.
|
6
|
+
|
7
|
+
def sh_success(cmd)
|
8
|
+
success = false
|
9
|
+
begin
|
10
|
+
success, status = sh cmd
|
11
|
+
rescue
|
12
|
+
# do nothing
|
13
|
+
end
|
14
|
+
|
15
|
+
success
|
16
|
+
end
|
17
|
+
|
18
|
+
def has_cmd(cmd)
|
19
|
+
sh_success "which #{cmd}"
|
20
|
+
end
|
21
|
+
|
22
|
+
THIS_DIR = File.expand_path(File.dirname(__FILE__))
|
23
|
+
APPIUM_DIR = "#{THIS_DIR}/appium"
|
24
|
+
|
25
|
+
GCC = '/usr/bin/gcc'
|
26
|
+
GCC42_CMD = 'gcc-4.2'
|
27
|
+
GCC42 = "/usr/local/bin/#{GCC42_CMD}"
|
28
|
+
|
29
|
+
file GCC do
|
30
|
+
fail "#{GCC} does not exist. This is likely because you do not have Xcode command line tools installed."
|
31
|
+
end
|
32
|
+
|
33
|
+
file GCC42 => [GCC] do
|
34
|
+
sh "ln -s #{GCC} #{GCC42}"
|
35
|
+
end
|
36
|
+
|
37
|
+
task :gcc do
|
38
|
+
if !has_cmd('gcc-4.2') then
|
39
|
+
Rake::Task[GCC42].invoke
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
task :java do
|
44
|
+
if !has_cmd('java') then
|
45
|
+
puts "You must install java to continue."
|
46
|
+
puts "cf. http://www.oracle.com/technetwork/java/javase/downloads/index.html"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
task :ruby => [:gcc] do
|
51
|
+
if has_cmd('rvm') then
|
52
|
+
# doesn't hurt anything if already installed
|
53
|
+
sh 'rvm install 2.0.0'
|
54
|
+
else
|
55
|
+
sh '\curl -L https://get.rvm.io | bash -s stable --ruby=2.0.0'
|
56
|
+
end
|
57
|
+
|
58
|
+
system '/bin/bash --login -i -c "rvm use --default 2.0.0"'
|
59
|
+
sh 'rvm osx-ssl-certs update all'
|
60
|
+
end
|
61
|
+
|
62
|
+
task :gems => [:ruby] do
|
63
|
+
sh 'gem update --system'
|
64
|
+
sh 'gem install --no-rdoc --no-ri bundler'
|
65
|
+
sh 'gem update'
|
66
|
+
sh 'gem cleanup'
|
67
|
+
sh 'gem uninstall -aIx appium_lib'
|
68
|
+
sh 'gem uninstall -aIx web_console'
|
69
|
+
sh 'gem install --no-rdoc --no-ri web_console'
|
70
|
+
sh 'gem uninstall -aIx flaky'
|
71
|
+
sh 'gem install --no-rdoc --no-ri flaky'
|
72
|
+
end
|
73
|
+
|
74
|
+
task :brew do
|
75
|
+
if has_cmd('brew') then
|
76
|
+
sh 'brew update'
|
77
|
+
else
|
78
|
+
sh 'ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
task :ant do
|
83
|
+
if !has_cmd('ant') then
|
84
|
+
fail "Ant must be installed to complete this setup."
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
task :maven do
|
89
|
+
if !has_cmd('mvn') then
|
90
|
+
Rake::Task[:brew].invoke
|
91
|
+
sh 'brew install maven'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
task :nodejs => [:brew] do
|
96
|
+
sh 'brew install node' # noop if already installed
|
97
|
+
if sh_success 'brew outdated | grep node' then
|
98
|
+
sh 'brew upgrade node'
|
99
|
+
end if
|
100
|
+
|
101
|
+
# make sure it's installed
|
102
|
+
sh 'node --version'
|
103
|
+
sh 'npm --version'
|
104
|
+
end
|
105
|
+
|
106
|
+
task :grunt => [:nodejs] do
|
107
|
+
if !sh_success('grunt --version') then
|
108
|
+
sh 'npm install -g grunt grunt-cli'
|
109
|
+
sh 'grunt --version'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# we only clone when the directory doesn't already exist
|
114
|
+
directory APPIUM_DIR do
|
115
|
+
cd THIS_DIR
|
116
|
+
sh 'git clone git://github.com/appium/appium.git'
|
117
|
+
end
|
118
|
+
|
119
|
+
# appium goes into the directory below where this Rakefile is
|
120
|
+
desc 'Downloads appium and all dependencies, and starts up appium. May require a superuser password.'
|
121
|
+
task :appium => [APPIUM_DIR, :grunt, :maven, :ant, :gems, :ruby, :java] do
|
122
|
+
cd APPIUM_DIR
|
123
|
+
sh 'git pull origin master'
|
124
|
+
sh './reset.sh'
|
125
|
+
|
126
|
+
begin
|
127
|
+
sh 'sudo `which grunt` authorize'
|
128
|
+
rescue
|
129
|
+
# grunt errors if it has already been authorized, so ... I guess we'll ignore errors then
|
130
|
+
end
|
131
|
+
|
132
|
+
sh 'node server.js'
|
133
|
+
end
|
134
|
+
|
135
|
+
task :default => :appium
|