appium_failure_helper 1.2.2 → 1.2.4

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: 86e61e520b2e2cce56bebabf72db737fc6a03ff65560c19143cc587f5fd2dea0
4
- data.tar.gz: 2af329dc1706e62a87d1aed5375db6deca8723856dc6256d99175337c30f2b28
3
+ metadata.gz: a496ea646258e4d0d11ee11e5d0424b9ce37099ad0ae578de7793508e2ce8196
4
+ data.tar.gz: ae1c2e4e1ea18407d2989541ed7461bee8252535de1437cc48288a9944246477
5
5
  SHA512:
6
- metadata.gz: b587b083e8f56ed81c8a30ae1e72da76c65fb0780cd0e06665652a17c87883982fa46fa69544aec20acdcdea84cec370b41487ced46587e8b42370dd15b192af
7
- data.tar.gz: 253066772c16ca173f1bd663a48ba05e3460eb03ff5cfff497fec194dd8ed1f350c179488aa25c6b5c629aacc26e582fc5355ed3a189d15d04f1906d196a9a60
6
+ metadata.gz: 5689dff21366fbacdb663189b0368c716399bdaf2434df6cf8db3ae68982fe4b29c11ef506b640472d18483eff659eea12c67ac1e76e35285406ef4c0eb2e8ce
7
+ data.tar.gz: f1075a47223d23ac6bd0f0bd0494a07e33a07791bfc95b1f8928791a80adde465a5fdd8125df4d79afe38d3a5b4f935526a5caefef600f3c6054a830d6755b2b
@@ -1,4 +1,3 @@
1
- # lib/appium_failure_helper/analyzer.rb
2
1
  module AppiumFailureHelper
3
2
  module Analyzer
4
3
  def self.triage_error(exception)
@@ -52,12 +51,10 @@ module AppiumFailureHelper
52
51
  def self.find_de_para_match(failed_info, element_map)
53
52
  failed_value = (failed_info || {})[:selector_value].to_s
54
53
  return nil if failed_value.empty?
55
-
56
54
  logical_name_key = failed_value.gsub(/^#/, '')
57
55
  if element_map.key?(logical_name_key)
58
56
  return { logical_name: logical_name_key, correct_locator: element_map[logical_name_key] }
59
57
  end
60
-
61
58
  cleaned_failed_locator = failed_value.gsub(/[:\-\/@=\[\]'"()]/, ' ').gsub(/\s+/, ' ').downcase.strip
62
59
  element_map.each do |name, locator_info|
63
60
  mapped_locator = (locator_info || {})['valor'].to_s
@@ -77,20 +74,16 @@ module AppiumFailureHelper
77
74
  failed_locator_value = (failed_info || {})[:selector_value]
78
75
  failed_locator_type = (failed_info || {})[:selector_type]
79
76
  return [] unless failed_locator_value && failed_locator_type
80
-
81
77
  normalized_failed_type = failed_locator_type.to_s.downcase.include?('id') ? 'id' : failed_locator_type.to_s
82
78
  cleaned_failed_locator = failed_locator_value.to_s.gsub(/[:\-\/@=\[\]'"()]/, ' ').gsub(/\s+/, ' ').downcase.strip
83
79
  similarities = []
84
-
85
- (all_page_suggestions || []).each do |suggestion|
80
+ all_page_suggestions.each do |suggestion|
86
81
  candidate_locator = (suggestion[:locators] || []).find { |loc| loc[:strategy] == normalized_failed_type }
87
82
  next unless candidate_locator
88
-
89
83
  cleaned_candidate_locator = candidate_locator[:locator].gsub(/[:\-\/@=\[\]'"()]/, ' ').gsub(/\s+/, ' ').downcase.strip
90
84
  distance = DidYouMean::Levenshtein.distance(cleaned_failed_locator, cleaned_candidate_locator)
91
85
  max_len = [cleaned_failed_locator.length, cleaned_candidate_locator.length].max
92
86
  next if max_len.zero?
93
-
94
87
  similarity_score = 1.0 - (distance.to_f / max_len)
95
88
  if similarity_score > 0.85
96
89
  similarities << { name: suggestion[:name], locators: suggestion[:locators], score: similarity_score, attributes: suggestion[:attributes] }
@@ -24,7 +24,13 @@ module AppiumFailureHelper
24
24
  return map
25
25
  end
26
26
  instance.elements.each do |key, value|
27
- map[key.to_s] = { 'tipoBusca' => value[0], 'valor' => value[1] }
27
+ valor = value[1]
28
+ if valor.is_a?(Hash)
29
+ valor_final = valor['valor'] || valor['value'] || valor
30
+ else
31
+ valor_final = valor
32
+ end
33
+ map[key.to_s] = { 'tipoBusca' => value[0], 'valor' => valor_final }
28
34
  end
29
35
  rescue => e
30
36
  Utils.logger.warn("AVISO: Erro ao processar o arquivo Ruby #{file_path}: #{e.message}")
@@ -1,4 +1,3 @@
1
- # lib/appium_failure_helper/handler.rb
2
1
  module AppiumFailureHelper
3
2
  class Handler
4
3
  def self.call(driver, exception)
@@ -16,19 +15,19 @@ module AppiumFailureHelper
16
15
  begin
17
16
  unless @driver && @driver.session_id
18
17
  Utils.logger.error("Helper não executado: driver nulo ou sessão encerrada.")
19
- Utils.logger.error("Exceção original: #{@exception.message}")
20
18
  return
21
19
  end
22
20
 
23
21
  FileUtils.mkdir_p(@output_folder)
24
22
 
23
+
25
24
  triage_result = Analyzer.triage_error(@exception)
26
25
 
27
26
  report_data = {
28
27
  exception: @exception,
29
28
  triage_result: triage_result,
30
29
  timestamp: @timestamp,
31
- platform: @driver.capabilities['platformName'] || @driver.capabilities[:platformName] || 'unknown',
30
+ platform: @driver.capabilities['platformName'] || @driver.capabilities[:platform_name] || 'unknown',
32
31
  screenshot_base64: @driver.screenshot_as(:base64)
33
32
  }
34
33
 
@@ -1,3 +1,3 @@
1
1
  module AppiumFailureHelper
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_failure_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Nascimento