testimonium 0.1.8.2 → 1.2.0
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 +4 -4
- data/bin/testimonium +1 -0
- data/lib/testimonium.rb +7 -4
- data/lib/testimonium/cli.rb +2 -2
- data/lib/testimonium/cli/helpers.rb +1 -1
- data/lib/testimonium/find_functions.rb +70 -0
- data/lib/testimonium/help_functions.rb +39 -0
- data/lib/testimonium/tap_functions.rb +32 -0
- data/lib/testimonium/validate_functions.rb +34 -0
- data/lib/testimonium/version.rb +1 -1
- metadata +7 -7
- data/lib/testimonium/findFunctions.rb +0 -46
- data/lib/testimonium/iosHelpFunctions.rb +0 -25
- data/lib/testimonium/tapFunctions.rb +0 -33
- data/lib/testimonium/validateFunctions.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d6661e3f0e21f8df37dd23a84fc92092445b8d9a6e256876b0661b3615206d7
|
4
|
+
data.tar.gz: e9c06ae626a5835604507cc18d0358b453b14ada9ae5a03b97ee0eaebe026df7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 731ef578679790ce44444ec4cb9d01efe81d4ca95195b4e4b5b5cd500c8bea498ff8e63b94862c84d93671eb1ff70a4907c88f974669f53e13e462819eea5693
|
7
|
+
data.tar.gz: 27c500ed8845606215f33485c1d061eba4a6f5c98ab15b732b264cc16a9df6d6b3b032eddc6b8b90e9aa2a3dd4247bdd6fb513502aa537ab5debe35b3696431a
|
data/bin/testimonium
CHANGED
data/lib/testimonium.rb
CHANGED
@@ -4,8 +4,11 @@
|
|
4
4
|
module Testimonium
|
5
5
|
require 'testimonium/cli'
|
6
6
|
require 'testimonium/version'
|
7
|
-
require 'testimonium/
|
8
|
-
require 'testimonium/
|
9
|
-
require 'testimonium/
|
10
|
-
require 'testimonium/
|
7
|
+
require 'testimonium/help_functions'
|
8
|
+
require 'testimonium/tap_functions'
|
9
|
+
require 'testimonium/validate_functions'
|
10
|
+
require 'testimonium/find_functions'
|
11
|
+
include Testimonium::Find
|
12
|
+
include Testimonium::Tap
|
13
|
+
include Testimonium::Validate
|
11
14
|
end
|
data/lib/testimonium/cli.rb
CHANGED
@@ -37,9 +37,9 @@ module Testimonium
|
|
37
37
|
when nil
|
38
38
|
print_usage
|
39
39
|
else
|
40
|
-
|
40
|
+
raise("Invalid command #{argument}.\nFor help use 'testimonium help'")
|
41
41
|
end
|
42
|
-
rescue => e
|
42
|
+
rescue StandardError => e
|
43
43
|
puts e.message.to_s
|
44
44
|
exit 1
|
45
45
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Testimonium
|
4
|
+
# Find functions
|
5
|
+
module Find
|
6
|
+
# Find element by xpath
|
7
|
+
def find_element_by_xpath(path, timeout = 3, retries = 5)
|
8
|
+
element = nil
|
9
|
+
count = 0
|
10
|
+
|
11
|
+
retries.times do
|
12
|
+
sleep timeout
|
13
|
+
count += 1
|
14
|
+
|
15
|
+
begin
|
16
|
+
element = find_element(:xpath, path)
|
17
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
18
|
+
end
|
19
|
+
|
20
|
+
log("Found on attempt #{count}") if element
|
21
|
+
return element if element
|
22
|
+
end
|
23
|
+
|
24
|
+
log("Failed to find: '#{path}'. Number of attempts: #{count}")
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
# Find element by element id
|
29
|
+
def find_element_by_id(id_string, timeout = 2, retries = 5)
|
30
|
+
find_element_id(id_string, timeout, retries)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Find element by text
|
34
|
+
def find_element_by_text(text_string, timeout = 2, retries = 5)
|
35
|
+
if device_android
|
36
|
+
return find_element_by_xpath("//*[@text='#{text_string}']", timeout, retries)
|
37
|
+
end
|
38
|
+
return find_text_ios(text_string, timeout, retries) if device_ios
|
39
|
+
end
|
40
|
+
|
41
|
+
# Android only: Needs app package name set as const. _ANDROID_PACKAGE_
|
42
|
+
def find_element_by_resourceid(id, timeout = 2, retries = 5)
|
43
|
+
if defined?(ANDROID_PACKAGE).nil?
|
44
|
+
log('ANDROID_PACKAGE variable is missing.')
|
45
|
+
raise Selenium::WebDriver::Error::NoSuchElementError
|
46
|
+
end
|
47
|
+
|
48
|
+
find_element_by_xpath("//*[@resource-id='#{ANDROID_PACKAGE}:id/#{id}']", timeout, retries)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Needs app package name set as const. _ANDROID_PACKAGE_
|
52
|
+
def find_all_elements_by_id(id_string, timeout = 2, retries = 5)
|
53
|
+
list = nil
|
54
|
+
|
55
|
+
retries.times do
|
56
|
+
sleep timeout
|
57
|
+
|
58
|
+
begin
|
59
|
+
list = ids(id_string) if device_android
|
60
|
+
list = find_elements(:id, id_string) if device_ios
|
61
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
62
|
+
end
|
63
|
+
|
64
|
+
return list if list
|
65
|
+
end
|
66
|
+
|
67
|
+
false
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
def find_function(function_type, parameter, timeout_time = 2, retries = 5)
|
4
|
+
element = nil
|
5
|
+
count = 0
|
6
|
+
|
7
|
+
retries.times do
|
8
|
+
sleep timeout_time
|
9
|
+
count += 1
|
10
|
+
|
11
|
+
begin
|
12
|
+
element = id(parameter) if function_type.eql?('id')
|
13
|
+
element = text(parameter) if function_type.eql?('text')
|
14
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
15
|
+
end
|
16
|
+
|
17
|
+
log("Found: '#{parameter}' on attempt #{count}") if element
|
18
|
+
return element if element
|
19
|
+
end
|
20
|
+
|
21
|
+
log("Failed to find: '#{function_type} = #{parameter}'. Number of attempts: #{count}")
|
22
|
+
false
|
23
|
+
end
|
24
|
+
|
25
|
+
def find_text_ios(parameter, timeout = 2, retries = 5)
|
26
|
+
find_function('text', parameter, timeout, retries)
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_element_id(parameter, timeout = 2, retries = 5)
|
30
|
+
find_function('id', parameter, timeout, retries)
|
31
|
+
end
|
32
|
+
|
33
|
+
def device_android
|
34
|
+
ENV['PLATFORM'] == 'android'
|
35
|
+
end
|
36
|
+
|
37
|
+
def device_ios
|
38
|
+
ENV['PLATFORM'] == 'ios'
|
39
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Testimonium
|
4
|
+
# Tap functions
|
5
|
+
module Tap
|
6
|
+
# Tap element by element id
|
7
|
+
def tap_element_by_id(id_string, timeout = 2, retries = 5)
|
8
|
+
find_element_by_id(id_string, timeout, retries).click
|
9
|
+
end
|
10
|
+
|
11
|
+
# Tap element by text
|
12
|
+
def tap_element_by_text(text_string, timeout = 2, retries = 5)
|
13
|
+
find_element_by_text(text_string, timeout, retries).click if device_android
|
14
|
+
find_text_ios(text_string, timeout, retries).click if device_ios
|
15
|
+
end
|
16
|
+
|
17
|
+
# Tap element by xpath
|
18
|
+
def tap_element_by_xpath(path, timeout = 2, retries = 5)
|
19
|
+
find_element_by_xpath(path, timeout, retries).click
|
20
|
+
end
|
21
|
+
|
22
|
+
# Android only: Needs app package name set as const. _ANDROID_PACKAGE_
|
23
|
+
def tap_element_by_resourceid(id, timeout = 2, retries = 5)
|
24
|
+
if defined?(ANDROID_PACKAGE).nil?
|
25
|
+
log('ANDROID_PACKAGE variable is missing.')
|
26
|
+
raise Selenium::WebDriver::Error::NoSuchElementError
|
27
|
+
end
|
28
|
+
|
29
|
+
find_element_by_resourceid(id, timeout, retries).click
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Testimonium
|
4
|
+
# Validate functions
|
5
|
+
module Validate
|
6
|
+
# Validate element by element id
|
7
|
+
def validate_element_by_id(id, timeout = 2, retries = 5)
|
8
|
+
unless find_element_by_id(id, timeout, retries)
|
9
|
+
raise Selenium::WebDriver::Error::NoSuchElementError
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Validate element by text
|
14
|
+
def validate_element_by_text(text, timeout = 5, retries = 5)
|
15
|
+
unless find_element_by_text(text, timeout, retries)
|
16
|
+
raise Selenium::WebDriver::Error::NoSuchElementError
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Validate element by xpath
|
21
|
+
def validate_element_by_xpath(path, timeout = 2, retries = 5)
|
22
|
+
unless find_element_by_xpath(path, timeout, retries)
|
23
|
+
raise Selenium::WebDriver::Error::NoSuchElementError
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Android only: Needs app package name set as const. _ANDROID_PACKAGE_
|
28
|
+
def validate_element_by_resourceid(id, timeout = 2, retries = 5)
|
29
|
+
unless find_element_by_resourceid(id, timeout, retries)
|
30
|
+
raise Selenium::WebDriver::Error::NoSuchElementError
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/testimonium/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testimonium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- M2mobi
|
@@ -56,10 +56,10 @@ files:
|
|
56
56
|
- lib/testimonium/cli/helpers.rb
|
57
57
|
- lib/testimonium/cli/run.rb
|
58
58
|
- lib/testimonium/cli/templates/env.rb.template
|
59
|
-
- lib/testimonium/
|
60
|
-
- lib/testimonium/
|
61
|
-
- lib/testimonium/
|
62
|
-
- lib/testimonium/
|
59
|
+
- lib/testimonium/find_functions.rb
|
60
|
+
- lib/testimonium/help_functions.rb
|
61
|
+
- lib/testimonium/tap_functions.rb
|
62
|
+
- lib/testimonium/validate_functions.rb
|
63
63
|
- lib/testimonium/version.rb
|
64
64
|
homepage:
|
65
65
|
licenses:
|
@@ -73,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '2.
|
76
|
+
version: '2.6'
|
77
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
79
|
- - ">="
|
@@ -83,5 +83,5 @@ requirements: []
|
|
83
83
|
rubygems_version: 3.0.3
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
|
-
summary: testimonium-
|
86
|
+
summary: testimonium-1.2.0
|
87
87
|
test_files: []
|
@@ -1,46 +0,0 @@
|
|
1
|
-
############
|
2
|
-
### Find ###
|
3
|
-
############
|
4
|
-
|
5
|
-
# Find element by xpath
|
6
|
-
def find_element_by_xpath(path, timeout = 2, retries = 5)
|
7
|
-
element = nil
|
8
|
-
|
9
|
-
retries.times do
|
10
|
-
sleep timeout
|
11
|
-
|
12
|
-
begin
|
13
|
-
element = find_element(:xpath, path)
|
14
|
-
rescue Selenium::WebDriver::Error::NoSuchElementError
|
15
|
-
end
|
16
|
-
|
17
|
-
return element if element
|
18
|
-
end
|
19
|
-
|
20
|
-
false
|
21
|
-
end
|
22
|
-
|
23
|
-
# Find element by element resource-id (Android only)
|
24
|
-
#
|
25
|
-
# Needs app package name set as const. _ANDROID_PACKAGE_
|
26
|
-
def find_element_by_resourceid(id, timeout = 2, retries = 5)
|
27
|
-
find_element_by_xpath("//*[@resource-id='#{ANDROID_PACKAGE}:id/#{ id }']", timeout, retries)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Find element by element id
|
31
|
-
def find_element_by_id(idString, timeout = 2, retries = 5)
|
32
|
-
if ENV['PLATFORM'] == 'android'
|
33
|
-
find_element_by_xpath("//*[@id='#{ idString }']", timeout, retries)
|
34
|
-
elsif ENV['PLATFORM'] == 'ios'
|
35
|
-
find_id_ios(idString)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# Find element by text
|
40
|
-
def find_element_by_text(textString, timeout = 2, retries = 5)
|
41
|
-
if ENV['PLATFORM'] == 'android'
|
42
|
-
find_element_by_xpath("//*[@text='#{ textString }']", timeout, retries)
|
43
|
-
elsif ENV['PLATFORM'] == 'ios'
|
44
|
-
find_text_ios(textString)
|
45
|
-
end
|
46
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
def find_text_ios(parameter, timeout = 2, retries = 5)
|
2
|
-
findFunctionForIos('text', parameter)
|
3
|
-
end
|
4
|
-
|
5
|
-
def find_id_ios(parameter, timeout = 2, retries = 5)
|
6
|
-
findFunctionForIos('id', parameter)
|
7
|
-
end
|
8
|
-
|
9
|
-
def findFunctionForIos(functionType, parameter, timeout = 2, retries = 5)
|
10
|
-
element = nil
|
11
|
-
|
12
|
-
retries.times do
|
13
|
-
sleep timeout
|
14
|
-
|
15
|
-
begin
|
16
|
-
element = id(parameter) if functionType.eql?('id')
|
17
|
-
element = text(parameter) if functionType.eql?('text')
|
18
|
-
rescue Selenium::WebDriver::Error::NoSuchElementError
|
19
|
-
end
|
20
|
-
|
21
|
-
return element if element
|
22
|
-
end
|
23
|
-
|
24
|
-
false
|
25
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
############
|
2
|
-
### TAP ###
|
3
|
-
############
|
4
|
-
|
5
|
-
# Tap element by element id
|
6
|
-
def tap_element_by_id(idString, timeout = 2, retries = 5)
|
7
|
-
if ENV['PLATFORM'] == 'android'
|
8
|
-
find_element_by_id(idString, timeout, retries).click
|
9
|
-
elsif ENV['PLATFORM'] == 'ios'
|
10
|
-
find_id_ios(idString).click
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Tap element by resource-id (Android only)
|
15
|
-
#
|
16
|
-
# Needs app package name set as const. _ANDROID_PACKAGE_
|
17
|
-
def tap_element_by_resourceid(id, timeout = 2, retries = 5)
|
18
|
-
find_element_by_resourceid(id, timeout, retries).click
|
19
|
-
end
|
20
|
-
|
21
|
-
# Tap element by text
|
22
|
-
def tap_element_by_text(textString, timeout = 2, retries = 5)
|
23
|
-
if ENV['PLATFORM'] == 'android'
|
24
|
-
find_element_by_text(textString, timeout, retries).click
|
25
|
-
elsif ENV['PLATFORM'] == 'ios'
|
26
|
-
find_text_ios(textString).click
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Tap element by xpath
|
31
|
-
def tap_element_by_xpath(path, timeout = 2, retries = 5)
|
32
|
-
find_element_by_xpath(path, timeout, retries).click
|
33
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
################
|
2
|
-
### Validate ###
|
3
|
-
################
|
4
|
-
|
5
|
-
# Validate element by element id
|
6
|
-
def validate_element_by_id(id, timeout = 2, retries = 5)
|
7
|
-
unless find_element_by_id(id, timeout, retries)
|
8
|
-
raise Selenium::WebDriver::Error::NoSuchElementError
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
# Validate element by resource-id (Android only)
|
13
|
-
#
|
14
|
-
# Needs app package name set as const. _ANDROID_PACKAGE_
|
15
|
-
def validate_element_by_resourceid(id, timeout = 2, retries = 5)
|
16
|
-
unless find_element_by_resourceid(id, timeout, retries)
|
17
|
-
raise Selenium::WebDriver::Error::NoSuchElementError
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# Validate element by text
|
22
|
-
def validate_element_by_text(text, timeout = 2, retries = 5)
|
23
|
-
if ENV['PLATFORM'] == 'android'
|
24
|
-
unless find_element_by_text(text, timeout, retries)
|
25
|
-
raise Selenium::WebDriver::Error::NoSuchElementError
|
26
|
-
end
|
27
|
-
elsif ENV['PLATFORM'] == 'ios'
|
28
|
-
unless find_text_ios(text, timeout, retries)
|
29
|
-
raise Selenium::WebDriver::Error::NoSuchElementError
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Validate element by xpath
|
35
|
-
def validate_element_by_xpath(path, timeout = 2, retries = 5)
|
36
|
-
unless find_element_by_xpath(path, timeout, retries)
|
37
|
-
raise Selenium::WebDriver::Error::NoSuchElementError
|
38
|
-
end
|
39
|
-
end
|