appium_connect 1.0.3 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/AppiumConnect.rb +25 -97
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67cfec0c21a368389681c95da28ec295fe6e2ff6
|
4
|
+
data.tar.gz: 4d7f695ee3d94ff5a510a580771fbccd9825f93e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 521906a600fd91564b457f63655945bb5dfc1c2c3c24c55c8cd090032c6570be6bdab4d84968d91c1d5380cf533a8f881fe16d152bafaf6b9b953ca960069d63
|
7
|
+
data.tar.gz: 26b3f0c31c4529271ebcb81d5e60363bb4c86778d6404b8f5cb7bc7eb26e922bfdeba1325841b6e63e5d2c34a096c71ecb07f00748012c99ea0e69cc7ad43e3e
|
data/lib/AppiumConnect.rb
CHANGED
@@ -1,105 +1,33 @@
|
|
1
|
+
#Copyright © 2016 Orasi Software, Inc., All rights reserved.
|
2
|
+
|
1
3
|
require 'parallel'
|
2
4
|
require 'json'
|
3
5
|
require 'fileutils'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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 = 'C:/temp/AppiumConnect'
|
11
19
|
end
|
12
20
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def appium_server_start(**options)
|
19
|
-
command = 'appium'
|
20
|
-
command << " --nodeconfig #{options[:config]}" if options.key?(:config)
|
21
|
-
command << " -p #{options[:port]}" if options.key?(:port)
|
22
|
-
command << " -bp #{options[:bp]}" if options.key?(:bp)
|
23
|
-
command << " --udid #{options[:udid]}" if options.key?(:udid)
|
24
|
-
command << " --automation-name #{options[:automationName]}" if options.key?(:automationName)
|
25
|
-
command << " --selendroid-port #{options[:selendroidPort]}" if options.key?(:selendroidPort)
|
26
|
-
command << " --log #{Dir.pwd}/output/#{options[:log]}" if options.key?(:log)
|
27
|
-
command << " --tmp /tmp/#{options[:tmp]}" if options.key?(:tmp)
|
28
|
-
command << " --chromedriver-port #{options[:cp]}" if options.key?(:cp)
|
29
|
-
command << " --command-timeout 180"
|
30
|
-
Dir.chdir('.') {
|
31
|
-
if Gem::Platform.local.os == 'linux'
|
32
|
-
pid = system('x-terminal-emulator -e ' + command)
|
33
|
-
elsif Gem::Platform.local.os == 'darwin'
|
34
|
-
`osascript -e 'tell app "Terminal" to do script "#{command}"'`
|
35
|
-
else
|
36
|
-
pid = system('start ' + command)
|
37
|
-
end
|
38
|
-
|
39
|
-
puts 'Waiting for Appium to start up...'
|
40
|
-
sleep 5
|
41
|
-
|
42
|
-
if pid.nil?
|
43
|
-
puts 'Appium server did not start :('
|
44
|
-
end
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
|
-
def generate_node_config(file_name, udid, appium_port, ip, hubIp, platform, browser)
|
49
|
-
f = File.new(Dir.pwd + "/node_configs/#{file_name}", "w")
|
50
|
-
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}],
|
51
|
-
configuration: { cleanUpCycle: 2000, timeout: 180000, registerCycle: 5000, proxy: "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", url: "http://" + ip + ":#{appium_port}/wd/hub",
|
52
|
-
host: ip, port: appium_port, maxSession: 1, register: true, hubPort: 4444, hubHost: hubIp } } ) )
|
53
|
-
f.close
|
54
|
-
end
|
21
|
+
create_dir nodeConfigDir
|
22
|
+
create_dir nodeConfigDir + '/node_configs'
|
23
|
+
create_dir nodeConfigDir + '/output'
|
55
24
|
|
56
|
-
def launch_hub_and_nodes(ip, hubIp)
|
57
25
|
|
58
|
-
|
59
|
-
|
60
|
-
ios_devices = JSON.parse(get_ios_devices)
|
61
|
-
|
62
|
-
ios_devices.size.times do |index|
|
63
|
-
port = 4100 + index
|
64
|
-
config_name = "#{ios_devices[index]["udid"]}.json"
|
65
|
-
generate_node_config config_name, ios_devices[index]["udid"], port, ip, hubIp, 'MAC', 'safari'
|
66
|
-
node_config = Dir.pwd + '/node_configs/' +"#{config_name}"
|
67
|
-
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"]
|
68
|
-
end
|
69
|
-
|
70
|
-
else
|
71
|
-
|
72
|
-
devices = JSON.parse(get_android_devices)
|
73
|
-
|
74
|
-
devices.size.times do |index|
|
75
|
-
port = 4000 + index
|
76
|
-
bp = 2250 + index
|
77
|
-
sdp = 5000 + index
|
78
|
-
cp = 6000 + index
|
79
|
-
sdkv = get_device_osv(devices[index]['udid']).strip.to_i
|
80
|
-
config_name = "#{devices[index]["udid"]}.json"
|
81
|
-
generate_node_config config_name, devices[index]["udid"], port, ip, hubIp, 'android', 'chrome'
|
82
|
-
node_config = Dir.pwd + '/node_configs/' +"#{config_name}"
|
83
|
-
if sdkv === 16 || sdkv === 17
|
84
|
-
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
|
85
|
-
else
|
86
|
-
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
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def create_dir(name)
|
93
|
-
FileUtils::mkdir_p name
|
94
|
-
end
|
95
|
-
|
96
|
-
create_dir 'node_configs'
|
97
|
-
create_dir 'output'
|
98
|
-
if File.exist?('config.json')
|
99
|
-
config = JSON.parse(File.read('config.json'))
|
26
|
+
if File.exist?(nodeConfigDir + '/config.json')
|
27
|
+
config = JSON.parse(File.read(nodeConfigDir +'/config.json'))
|
100
28
|
|
101
29
|
puts ''
|
102
|
-
puts 'Config file detected. Press enter to use last setting:'
|
30
|
+
puts 'Config file detected. Press enter to use last setting or any other key to edit:'
|
103
31
|
puts "Hub: #{config['hubIp']} Node: #{config['nodeIp']}"
|
104
32
|
|
105
33
|
if gets.chomp() != ''
|
@@ -115,7 +43,7 @@ if File.exist?('config.json')
|
|
115
43
|
ip = gets.chomp()
|
116
44
|
|
117
45
|
config = {hubIp: hubIp, nodeIp: ip}
|
118
|
-
File.open('config.json', 'w') do |f|
|
46
|
+
File.open(nodeConfigDir + '/config.json', 'w') do |f|
|
119
47
|
f.write(config.to_json)
|
120
48
|
end
|
121
49
|
|
@@ -133,12 +61,12 @@ else
|
|
133
61
|
ip = gets.chomp()
|
134
62
|
|
135
63
|
config = {hubIp: hubIp, nodeIp: ip}
|
136
|
-
|
64
|
+
|
65
|
+
File.open(nodeConfigDir + '/config.json', 'w') do |f|
|
137
66
|
f.write(config.to_json)
|
138
67
|
end
|
139
68
|
|
140
69
|
end
|
141
70
|
|
142
71
|
|
143
|
-
|
144
|
-
launch_hub_and_nodes(config['nodeIp'], config['hubIp'])
|
72
|
+
launch_hub_and_nodes(config['nodeIp'], config['hubIp'], nodeConfigDir)
|