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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/AppiumConnect.rb +25 -97
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9b967c348561740f948f409e4c67caa1b5e3cba
4
- data.tar.gz: 43929ae7578789df6c93e32ac54bfb5f26f36920
3
+ metadata.gz: 67cfec0c21a368389681c95da28ec295fe6e2ff6
4
+ data.tar.gz: 4d7f695ee3d94ff5a510a580771fbccd9825f93e
5
5
  SHA512:
6
- metadata.gz: df25de0f3ab83297fac762e654b687b4a9151c5fc962d43c7dc1735eedf1d1ccdaaeb2d885c07bb2814196cdaedb97ee1a59b9c8edb9fd806d65ce3106e506ff
7
- data.tar.gz: 8201cef269e960a3647276d93101fbcf1914ed6ab23fe5732d394ce4f894f92a4ae095e70c96fa204cdc192de9453440fa52c2425ef1238a343d4d590bb2cd70
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
- def get_android_devices
6
- 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 } })
7
- end
8
-
9
- def get_ios_devices
10
- ENV["IOS_DEVICES"] = JSON.generate((`system_profiler SPUSBDataType | sed -n -E -e '/(iPhone|iPad)/,/Serial/s/ *Serial Number: *(.+)/\\1/p'`).lines.map.each_with_index { |line, index| { udid: line.gsub(/\n/,""), thread: index + 1 } })
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
- def get_device_osv udid
14
- command = "adb -s #{udid} shell getprop ro.build.version.sdk"
15
- `#{command}`
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
- if Gem::Platform.local.os == 'darwin'
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
- File.open('config.json', 'w') do |f|
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Watson