appium_failure_helper 1.5.2 → 1.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cd745bb113c891cb16c719c8a21b010a1ca8041ef509a71317c69d995063d34
4
- data.tar.gz: 23783f539af7afe215828999f41e2ea31c73a1956b2bc942fbb9064288afed50
3
+ metadata.gz: 98b490f90ffbc00dd772d504e4ffcf1ef2ee25d25004a74458ca9e6ada556b1f
4
+ data.tar.gz: 7fe8c205a04b7944977651441408b5f4ae92e37b0c8acbb5d45a8de36315fcf5
5
5
  SHA512:
6
- metadata.gz: 36fc1daa46251ba0148e8ca220936da26e6893d18b9b2815e46e0fa834c7eb1160b8a66faf699241293904ad3241fc084792a61f2456e1afcf7e674f0749e753
7
- data.tar.gz: 4205ee7d482098816a164abb0bd2d59f01a81fdbc4ad29732375b6eab22124449f5633c41219936c56a56e0a4c9406bfb55b2c916c715f01e73fe95cb25b4b7c
6
+ metadata.gz: 7a8d1778dab86262461041523686d000a3df6d30d51f6aa222c50a1b9037c782f5aa5622af57b030127c6d9c9d9b6fd241d21cf25a084da3af6ad4894c1e02bd
7
+ data.tar.gz: 1ed02d956de5335cb5f8cdefa065314013c90a96b4afc50f65656dce7569dd54967024c8a78fcf9bf403a5a9fa1a45c8c73c5e83ddcf5cdf63a99b5181b55228
@@ -31,17 +31,18 @@
31
31
  <orderEntry type="library" scope="PROVIDED" name="psych (v5.2.6, ruby-3.1.7-p261) [gem]" level="application" />
32
32
  <orderEntry type="library" scope="PROVIDED" name="racc (v1.8.1, ruby-3.1.7-p261) [gem]" level="application" />
33
33
  <orderEntry type="library" scope="PROVIDED" name="rake (v13.3.0, ruby-3.1.7-p261) [gem]" level="application" />
34
- <orderEntry type="library" scope="PROVIDED" name="rdoc (v6.14.2, ruby-3.1.7-p261) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="rdoc (v6.15.0, ruby-3.1.7-p261) [gem]" level="application" />
35
35
  <orderEntry type="library" scope="PROVIDED" name="reline (v0.6.2, ruby-3.1.7-p261) [gem]" level="application" />
36
36
  <orderEntry type="library" scope="PROVIDED" name="rspec (v3.13.1, ruby-3.1.7-p261) [gem]" level="application" />
37
37
  <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.13.5, ruby-3.1.7-p261) [gem]" level="application" />
38
38
  <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.13.5, ruby-3.1.7-p261) [gem]" level="application" />
39
39
  <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.13.5, ruby-3.1.7-p261) [gem]" level="application" />
40
40
  <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.13.6, ruby-3.1.7-p261) [gem]" level="application" />
41
- <orderEntry type="library" scope="PROVIDED" name="rubyzip (v3.1.0, ruby-3.1.7-p261) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="rubyzip (v3.1.1, ruby-3.1.7-p261) [gem]" level="application" />
42
42
  <orderEntry type="library" scope="PROVIDED" name="selenium-webdriver (v3.142.7, ruby-3.1.7-p261) [gem]" level="application" />
43
43
  <orderEntry type="library" scope="PROVIDED" name="stringio (v3.1.7, ruby-3.1.7-p261) [gem]" level="application" />
44
44
  <orderEntry type="library" scope="PROVIDED" name="tomlrb (v1.3.0, ruby-3.1.7-p261) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="tsort (v0.2.0, ruby-3.1.7-p261) [gem]" level="application" />
45
46
  <orderEntry type="library" scope="PROVIDED" name="websocket-driver (v0.7.7, ruby-3.1.7-p261) [gem]" level="application" />
46
47
  <orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.5, ruby-3.1.7-p261) [gem]" level="application" />
47
48
  </component>
@@ -38,40 +38,74 @@ module AppiumFailureHelper
38
38
 
39
39
  def self.perform_advanced_analysis(failed_info, all_page_elements, platform)
40
40
  return nil if failed_info.empty? || all_page_elements.empty?
41
+
41
42
  expected_attrs = parse_locator(failed_info[:selector_type], failed_info[:selector_value], platform)
42
43
  return nil if expected_attrs.empty?
43
44
 
44
- id_key_to_check = (platform.to_s == 'ios') ? 'name' : 'resource-id'
45
- candidates = all_page_elements.map do |element_on_screen|
45
+ id_key = (platform.to_s == 'ios') ? 'name' : 'resource-id'
46
+ candidates = []
47
+
48
+ all_page_elements.each do |element_on_screen|
46
49
  score = 0
47
50
  analysis = {}
51
+ screen_attrs = element_on_screen[:attributes]
48
52
 
49
- if expected_attrs[id_key_to_check]
50
- actual_id = element_on_screen[:attributes][id_key_to_check]
51
- distance = DidYouMean::Levenshtein.distance(expected_attrs[id_key_to_check].to_s, actual_id.to_s)
52
- max_len = [expected_attrs[id_key_to_check].to_s.length, actual_id.to_s.length].max
53
- similarity = max_len.zero? ? 0 : 1.0 - (distance.to_f / max_len)
53
+ # Compara ID (pontuação máxima)
54
+ if expected_attrs[id_key] && screen_attrs[id_key]
55
+ similarity = calculate_similarity(expected_attrs[id_key], screen_attrs[id_key])
54
56
  score += 100 * similarity
55
- analysis[id_key_to_check.to_sym] = { similarity: similarity, expected: expected_attrs[id_key_to_check], actual: actual_id }
57
+ analysis[id_key.to_sym] = { similarity: similarity, expected: expected_attrs[id_key], actual: screen_attrs[id_key] }
58
+ end
59
+
60
+ # Compara Texto (pontuação média)
61
+ if expected_attrs['text'] && screen_attrs['text']
62
+ similarity = calculate_similarity(expected_attrs['text'], screen_attrs['text'])
63
+ score += 50 * similarity
64
+ analysis[:text] = { similarity: similarity, expected: expected_attrs['text'], actual: screen_attrs['text'] }
65
+ end
66
+
67
+ # Compara Content Description (pontuação alta para Android)
68
+ if expected_attrs['content-desc'] && screen_attrs['content-desc']
69
+ similarity = calculate_similarity(expected_attrs['content-desc'], screen_attrs['content-desc'])
70
+ score += 50 * similarity
71
+ analysis[:'content-desc'] = { similarity: similarity, expected: expected_attrs['content-desc'], actual: screen_attrs['content-desc'] }
56
72
  end
57
73
 
58
- { score: score, name: element_on_screen[:name], attributes: element_on_screen[:attributes], analysis: analysis } if score > 75
59
- end.compact
74
+ if score > 50 # Limiar mínimo para ser considerado um candidato
75
+ candidates << {
76
+ score: score,
77
+ name: element_on_screen[:name],
78
+ attributes: element_on_screen[:attributes],
79
+ analysis: analysis
80
+ }
81
+ end
82
+ end
60
83
 
61
84
  candidates.sort_by { |c| -c[:score] }.first
62
85
  end
63
86
 
64
87
  private
88
+ def self.calculate_similarity(expected, actual)
89
+ return 0 if expected.nil? || actual.nil?
90
+ distance = DidYouMean::Levenshtein.distance(expected.to_s, actual.to_s)
91
+ max_len = [expected.to_s.length, actual.to_s.length].max
92
+ max_len.zero? ? 1.0 : 1.0 - (distance.to_f / max_len)
93
+ end
65
94
 
66
95
  def self.parse_locator(type, value, platform)
67
96
  attrs = {}
97
+ type = type.to_s.downcase
98
+
68
99
  if platform.to_s == 'ios'
69
- attrs['name'] = value if type.to_s.include?('id')
100
+ attrs['name'] = value if type.include?('id')
70
101
  else # Android
71
- attrs['resource-id'] = value if type.to_s.include?('id')
102
+ attrs['resource-id'] = value if type.include?('id')
72
103
  end
73
- if type.to_s == 'xpath'
74
- value.scan(/@([\w\-]+)='([^']+)'/).each { |match| attrs[match[0]] = match[1] }
104
+
105
+ if type == 'xpath'
106
+ value.scan(/@([\w\-]+)='([^']+)'/).each do |match|
107
+ attrs[match[0]] = match[1]
108
+ end
75
109
  end
76
110
  attrs
77
111
  end
@@ -1,3 +1,3 @@
1
1
  module AppiumFailureHelper
2
- VERSION = "1.5.2"
2
+ VERSION = "1.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_failure_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Nascimento
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-10-04 00:00:00.000000000 Z
11
+ date: 2025-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -99,9 +99,6 @@ files:
99
99
  - LICENSE.txt
100
100
  - README.md
101
101
  - Rakefile
102
- - appium_failure_helper-1.5.1.gem
103
- - elements/cadastro.yaml
104
- - elements/login.yaml
105
102
  - img/fluxo_appium_failure_helper.png
106
103
  - lib/appium_failure_helper.rb
107
104
  - lib/appium_failure_helper/analyzer.rb
Binary file
@@ -1,7 +0,0 @@
1
- ---
2
- btnConfirmar:
3
- type: id
4
- value: confirm_button
5
- inputEmail:
6
- type: xpath
7
- value: "//android.widget.EditText"
data/elements/login.yaml DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- btnLogin:
3
- type: id
4
- value: com.app:id/login_button