appium_connect 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b47f43ab298b719f1399f4f94be587703c52715b
4
- data.tar.gz: 536d7f5b71f20ef9eabdfa7d67918385ed001727
3
+ metadata.gz: 0bc443e180f4662bda079df193410f80590896a9
4
+ data.tar.gz: 35ccaba6f77978aa18c6f0d116f2cbcffc214b9b
5
5
  SHA512:
6
- metadata.gz: 087d49389e67c5b1b04cf6d781c1db77a728d1ad068a80fca12aa6ac114df806e1d1c8949344899356ece4ede0dab014aa3c2ef6f2481e6b2d407301555fc536
7
- data.tar.gz: 8b5f64d4a27fbe4cd71f7628970088ce165a6caddbbfc32039fcdfd064cd14c9807d0a527c5db758719c2105d797534fa9470c6087eae8ea1865e88dc1cd05f0
6
+ metadata.gz: 96b27ad393df90e1b3cba1ed4ff7a67ab308317d31c68cc7f4cec4a78916ab7bba8775e858fc10be3e444115146cd161baae7c101bb7090ac7183d37ddf516d8
7
+ data.tar.gz: 7950519b8e5f0ccc41d03f780b6067a21c92b4ff4852a4a5fed4022235fc3840f2ee4ecf912bf5713e0ac53f49e86cdf8b0012edf34195a3125c9b0d8ddf9096
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,68 @@
1
+
2
+ def appium_server_start(**options)
3
+ command = 'appium'
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
+ if Gem::Platform.local.os == 'darwin'
37
+
38
+ ios_devices = JSON.parse(get_ios_devices)
39
+
40
+ ios_devices.size.times do |index|
41
+ port = 4100 + index
42
+ config_name = "#{ios_devices[index]["udid"]}.json"
43
+ generate_node_config nodeDir, config_name, ios_devices[index]["udid"], port, ip, hubIp, 'MAC', 'safari'
44
+ node_config = nodeDir + 'node_configs/' +"#{config_name}"
45
+ 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"]
46
+ end
47
+
48
+ else
49
+
50
+ devices = JSON.parse(get_android_devices)
51
+
52
+ devices.size.times do |index|
53
+ port = 4000 + index
54
+ bp = 2250 + index
55
+ sdp = 5000 + index
56
+ cp = 6000 + index
57
+ sdkv = get_device_osv(devices[index]['udid']).strip.to_i
58
+ config_name = "#{devices[index]["udid"]}.json"
59
+ generate_node_config nodeDir, config_name, devices[index]["udid"], port, ip, hubIp, 'android', 'chrome'
60
+ node_config = nodeDir + 'node_configs/' +"#{config_name}"
61
+ if sdkv === 16 || sdkv === 17
62
+ 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
63
+ else
64
+ 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
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,23 @@
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
+ 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}],
15
+ configuration: { cleanUpCycle: 2000, timeout: 180000, registerCycle: 5000, proxy: "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", url: "http://" + ip + ":#{appium_port}/wd/hub",
16
+ host: ip, port: appium_port, maxSession: 1, register: true, hubPort: 4444, hubHost: hubIp } } ) )
17
+ f.close
18
+ end
19
+
20
+
21
+ def create_dir(name)
22
+ FileUtils::mkdir_p name
23
+ end
data/lib/iOS.rb ADDED
@@ -0,0 +1,3 @@
1
+ def get_ios_devices
2
+ 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 } })
3
+ end
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.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Watson
@@ -19,7 +19,11 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - bin/AppiumConnect
22
+ - lib/Android.rb
23
+ - lib/Appium.rb
22
24
  - lib/AppiumConnect.rb
25
+ - lib/FileSystemHelpers.rb
26
+ - lib/iOS.rb
23
27
  homepage: https://github.com/Mattwhooo/AppiumConnect
24
28
  licenses:
25
29
  - MIT