appium_connect_pi 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/AppiumConnect +3 -0
- data/lib/Android.rb +8 -0
- data/lib/Appium.rb +69 -0
- data/lib/AppiumConnect.rb +71 -0
- data/lib/FileSystemHelpers.rb +24 -0
- data/lib/iOS.rb +3 -0
- metadata +51 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c9b5ba0133327b029a28aafcd20d47c90e07afdf
|
4
|
+
data.tar.gz: 797300c823520c2a2bafc9d49c1a626adc056398
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3ba1a6da97b29d980b714c03c807f8ce0151d0f6331fc18a7192233b4ce2125f7d816e75bd76aa5aa0c921cd848b729fd73e751041745a607dbff9d74d7976ce
|
7
|
+
data.tar.gz: 08d6d09cd6f4a7959632adb7ab04256c32358e6c77399ca3bf7cddc6c1e1d2eadecd5f50e184f9090384c5e7b95701038d2910bc881d9cb329ab8d1b3e354f02
|
data/bin/AppiumConnect
ADDED
data/lib/Android.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
def get_android_devices
|
2
|
+
ENV["DEVICES"] = JSON.generate((`adb devices`).lines.select { |line| line.match(/\tdevice$/) }.map.each_with_index { |line, index| { udid: line.split("\t")[0], thread: index + 1 } })
|
3
|
+
end
|
4
|
+
|
5
|
+
def get_device_osv udid
|
6
|
+
command = "adb -s #{udid} shell getprop ro.build.version.sdk"
|
7
|
+
`#{command}`
|
8
|
+
end
|
data/lib/Appium.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
|
2
|
+
def appium_server_start(**options)
|
3
|
+
command = 'node /home/pi/appium/bin/appium.js'
|
4
|
+
command << " --nodeconfig #{options[:config]}" if options.key?(:config)
|
5
|
+
command << " -p #{options[:port]}" if options.key?(:port)
|
6
|
+
command << " -bp #{options[:bp]}" if options.key?(:bp)
|
7
|
+
command << " --udid #{options[:udid]}" if options.key?(:udid)
|
8
|
+
command << " --automation-name #{options[:automationName]}" if options.key?(:automationName)
|
9
|
+
command << " --selendroid-port #{options[:selendroidPort]}" if options.key?(:selendroidPort)
|
10
|
+
command << " --log #{Dir.pwd}/output/#{options[:log]}" if options.key?(:log)
|
11
|
+
command << " --tmp /tmp/#{options[:tmp]}" if options.key?(:tmp)
|
12
|
+
command << " --chromedriver-port #{options[:cp]}" if options.key?(:cp)
|
13
|
+
command << " --command-timeout 180"
|
14
|
+
Dir.chdir('.') {
|
15
|
+
if Gem::Platform.local.os == 'linux'
|
16
|
+
pid = system('x-terminal-emulator -e ' + command)
|
17
|
+
elsif Gem::Platform.local.os == 'darwin'
|
18
|
+
`osascript -e 'tell app "Terminal" to do script "#{command}"'`
|
19
|
+
else
|
20
|
+
pid = system('start ' + command)
|
21
|
+
end
|
22
|
+
|
23
|
+
puts 'Waiting for Appium to start up...'
|
24
|
+
sleep 5
|
25
|
+
|
26
|
+
if pid.nil?
|
27
|
+
puts 'Appium server did not start :('
|
28
|
+
end
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
def launch_hub_and_nodes(ip, hubIp, nodeDir)
|
35
|
+
|
36
|
+
|
37
|
+
if Gem::Platform.local.os == 'darwin'
|
38
|
+
|
39
|
+
ios_devices = JSON.parse(get_ios_devices)
|
40
|
+
|
41
|
+
ios_devices.size.times do |index|
|
42
|
+
port = 4100 + index
|
43
|
+
config_name = "#{ios_devices[index]["udid"]}.json"
|
44
|
+
generate_node_config nodeDir, config_name, ios_devices[index]["udid"], port, ip, hubIp, 'MAC', 'safari'
|
45
|
+
node_config = nodeDir + '/node_configs/' +"#{config_name}"
|
46
|
+
appium_server_start config: node_config, port: port, udid: ios_devices[index]["udid"], log: "appium-#{ios_devices[index]["udid"]}.log", tmp: ios_devices[index]["udid"]
|
47
|
+
end
|
48
|
+
|
49
|
+
else
|
50
|
+
|
51
|
+
devices = JSON.parse(get_android_devices)
|
52
|
+
|
53
|
+
devices.size.times do |index|
|
54
|
+
port = 4000 + index
|
55
|
+
bp = 2250 + index
|
56
|
+
sdp = 5000 + index
|
57
|
+
cp = 6000 + index
|
58
|
+
sdkv = get_device_osv(devices[index]['udid']).strip.to_i
|
59
|
+
config_name = "#{devices[index]["udid"]}.json"
|
60
|
+
generate_node_config nodeDir, config_name, devices[index]["udid"], port, ip, hubIp, 'android', 'chrome'
|
61
|
+
node_config = nodeDir + '/node_configs/' +"#{config_name}"
|
62
|
+
if sdkv === 16 || sdkv === 17
|
63
|
+
appium_server_start config: node_config, port: port, bp: bp, udid: devices[index]["udid"], automationName: "selendroid", selendroidPort: sdp, log: "appium-#{devices[index]["udid"]}.log", tmp: devices[index]["udid"], cp: cp
|
64
|
+
else
|
65
|
+
appium_server_start config: node_config, port: port, bp: bp, udid: devices[index]["udid"], log: "appium-#{devices[index]["udid"]}.log", tmp: devices[index]["udid"], cp: cp
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#Copyright © 2016 Orasi Software, Inc., All rights reserved.
|
2
|
+
|
3
|
+
require 'parallel'
|
4
|
+
require 'json'
|
5
|
+
require 'fileutils'
|
6
|
+
require_relative 'FileSystemHelpers'
|
7
|
+
require_relative 'Android'
|
8
|
+
require_relative 'Appium'
|
9
|
+
require_relative 'iOS.rb'
|
10
|
+
|
11
|
+
|
12
|
+
platform = get_platform()
|
13
|
+
if platform == :linux
|
14
|
+
nodeConfigDir = File.expand_path('~/AppiumConnect/')
|
15
|
+
elsif platform == :mac
|
16
|
+
nodeConfigDir = File.expand_path('~/AppiumConnect/')
|
17
|
+
elsif platform == :windows
|
18
|
+
nodeConfigDir = Dir.home() + '/AppiumConnect'
|
19
|
+
end
|
20
|
+
|
21
|
+
create_dir nodeConfigDir
|
22
|
+
create_dir nodeConfigDir + '/node_configs'
|
23
|
+
create_dir nodeConfigDir + '/output'
|
24
|
+
|
25
|
+
|
26
|
+
if File.exist?(nodeConfigDir + '/config.json')
|
27
|
+
config = JSON.parse(File.read(nodeConfigDir +'/config.json'))
|
28
|
+
|
29
|
+
puts ''
|
30
|
+
puts 'Config file detected. Press enter to use last setting or any other key to edit:'
|
31
|
+
puts "Hub: #{config['hubIp']} Node: #{config['nodeIp']}"
|
32
|
+
|
33
|
+
if gets.chomp() != ''
|
34
|
+
|
35
|
+
puts ''
|
36
|
+
puts 'Please Enter IP address of Hub:'
|
37
|
+
hubIp = gets.chomp()
|
38
|
+
|
39
|
+
puts ''
|
40
|
+
puts ''
|
41
|
+
puts 'Please Enter IP address of Node:'
|
42
|
+
|
43
|
+
ip = gets.chomp()
|
44
|
+
|
45
|
+
config = {hubIp: hubIp, nodeIp: ip}
|
46
|
+
File.open(nodeConfigDir + '/config.json', 'w') do |f|
|
47
|
+
f.write(config.to_json)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
else
|
52
|
+
|
53
|
+
puts ''
|
54
|
+
puts 'Please Enter IP address of Hub:'
|
55
|
+
hubIp = gets.chomp()
|
56
|
+
|
57
|
+
puts ''
|
58
|
+
puts ''
|
59
|
+
puts 'Please Enter IP address of Node:'
|
60
|
+
ip = gets.chomp()
|
61
|
+
|
62
|
+
config = {hubIp: hubIp, nodeIp: ip}
|
63
|
+
|
64
|
+
File.open(nodeConfigDir + '/config.json', 'w') do |f|
|
65
|
+
f.write(config.to_json)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
launch_hub_and_nodes config[:nodeIp], config[:hubIp], nodeConfigDir
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
def get_platform()
|
3
|
+
if Gem::Platform.local.os == 'darwin'
|
4
|
+
return :mac
|
5
|
+
elsif Gem::Platform.local.os == 'linux'
|
6
|
+
return :linux
|
7
|
+
else
|
8
|
+
return :windows
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate_node_config(nodeDir, file_name, udid, appium_port, ip, hubIp, platform, browser)
|
13
|
+
f = File.new(nodeDir + "/node_configs/#{file_name}", "w")
|
14
|
+
|
15
|
+
f.write( JSON.generate({ capabilities: [{ udid: udid, browserName: udid, maxInstances: 1, platform: platform, deviceName: udid },{ browserName: browser, maxInstances: 1, deviceName: udid, udid: udid, seleniumProtocol: 'WebDriver', platform: platform , applicationName: udid}],
|
16
|
+
configuration: { cleanUpCycle: 2000, timeout: 180000, registerCycle: 5000, proxy: "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", url: "http://#{ip}:#{appium_port}/wd/hub",
|
17
|
+
host: ip, port: appium_port, maxSession: 1, register: true, hubPort: 4444, hubHost: hubIp } } ) )
|
18
|
+
f.close
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def create_dir(name)
|
23
|
+
FileUtils::mkdir_p name
|
24
|
+
end
|
data/lib/iOS.rb
ADDED
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: appium_connect_pi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.12
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Watson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Looks for USB Connected devices and registers them as Appium Nodes on
|
14
|
+
Selenium Grid
|
15
|
+
email: Watson.Mattc@gmail.com
|
16
|
+
executables:
|
17
|
+
- AppiumConnect
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/AppiumConnect
|
22
|
+
- lib/Android.rb
|
23
|
+
- lib/Appium.rb
|
24
|
+
- lib/AppiumConnect.rb
|
25
|
+
- lib/FileSystemHelpers.rb
|
26
|
+
- lib/iOS.rb
|
27
|
+
homepage: https://github.com/Mattwhooo/AppiumConnect
|
28
|
+
licenses:
|
29
|
+
- MIT
|
30
|
+
metadata: {}
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 2.4.6
|
48
|
+
signing_key:
|
49
|
+
specification_version: 4
|
50
|
+
summary: Quickly Connect USB connected device to Selenium Grid
|
51
|
+
test_files: []
|