appium_failure_helper 1.10.1 → 1.10.2

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: 51a04db2050508826da2df00704d3c09dd27396b16cbdb6daa465a01069ddb1c
4
- data.tar.gz: b6c523d78d7f0694b17b8e7aec538a972ff7b9885de05a4ccee057a76613c806
3
+ metadata.gz: 3e3447e2fe35beca0103d353b7af1c813ff9156fefc2d9136f5f994657d89618
4
+ data.tar.gz: 995aa92585cc7ef2a77b01f7525087afca3fec4210ad31e06cb5c0369654f5a8
5
5
  SHA512:
6
- metadata.gz: a42471ed673f57d2c60a3c6b74d333eaf8e319db233505c4c75972c5d8d199b74f9d8fd5cdd657db016ebc5c9f5e6c1e6ddf0cf305b13f79758637b5b5bc8662
7
- data.tar.gz: ca095c221019f692059ee9c5e014a0639e7a286e421ad049b6f5763a5830a7a89893bb746927cd44763b19f1a856289237efff1777780cc08228a82770c5adce
6
+ metadata.gz: 52ccddb3b7ae55782951d513b60d70debf1e0961876e89cb7c0bc017187ac56e025752f9063cda6e860fa86575610c9d0968daac9e890872f3d397ac85171cf1
7
+ data.tar.gz: b2888de94b644d082737ea8becc829517aa8d5e99d99176b1a5a61108a2b9076b1fb173dfda250afa3355e6f885e242f02589cf3862b8119405a6ea1b97d5417
@@ -34,31 +34,13 @@ module AppiumFailureHelper
34
34
 
35
35
  if triage_result == :locator_issue
36
36
  page_source = safe_page_source
37
- # tenta extrair detalhes do Analyzer (se existir), senão usa fetch_failed_element
38
- failed_info = {}
39
- begin
40
- failed_info = Analyzer.extract_failure_details(@exception) if Analyzer.respond_to?(:extract_failure_details)
41
- rescue
42
- failed_info = {}
43
- end
44
-
45
- if failed_info.nil? || failed_info.empty?
46
- # tenta extrair do próprio handler (regex mais robusta)
47
- failed_info = fetch_failed_element || {}
48
- end
37
+ failed_info = fetch_failed_element || {}
49
38
 
50
- # fallback para extrair do código-fonte (se existir)
51
- if (failed_info.nil? || failed_info.empty?) && SourceCodeAnalyzer.respond_to?(:extract_from_exception)
52
- begin
53
- failed_info = SourceCodeAnalyzer.extract_from_exception(@exception) || {}
54
- rescue
55
- failed_info = {}
56
- end
39
+ if failed_info.empty? && SourceCodeAnalyzer.respond_to?(:extract_from_exception)
40
+ failed_info = SourceCodeAnalyzer.extract_from_exception(@exception) || {}
57
41
  end
58
42
 
59
- # garante que exista ao menos um objeto failed_element
60
- if failed_info.nil? || failed_info.empty?
61
- failed_info = { selector_type: 'unknown', selector_value: @exception&.message.to_s }
43
+ if failed_info.empty?
62
44
  report_data[:triage_result] = :unidentified_locator_issue
63
45
  end
64
46
 
@@ -66,51 +48,31 @@ module AppiumFailureHelper
66
48
  best_candidate_analysis = nil
67
49
  alternative_xpaths = []
68
50
 
69
- if page_source
70
- begin
71
- doc = Nokogiri::XML(page_source)
72
- page_analyzer = PageAnalyzer.new(page_source, platform)
73
- all_page_elements = page_analyzer.analyze || []
74
- best_candidate_analysis = Analyzer.perform_advanced_analysis(failed_info, all_page_elements, platform) rescue nil
75
- rescue => e
76
- Utils.logger.warn("Erro analisando page_source: #{e.message}")
77
- end
78
- end
79
-
80
- # se não encontrou candidato, gera alternativas a partir do locator bruto
81
- if best_candidate_analysis.nil?
82
- # tenta parse por Analyzer (se exposto), senão regex fallback
83
- failed_attrs = {}
84
- begin
85
- if Analyzer.respond_to?(:parse_locator) || Analyzer.private_methods.include?(:parse_locator)
86
- failed_attrs = Analyzer.send(:parse_locator, failed_info[:selector_type], failed_info[:selector_value], platform) rescue {}
87
- end
88
- rescue
89
- failed_attrs = {}
90
- end
91
-
92
- if failed_attrs.nil? || failed_attrs.empty?
51
+ if page_source && !failed_info.empty?
52
+ doc = Nokogiri::XML(page_source)
53
+ page_analyzer = PageAnalyzer.new(page_source, platform)
54
+ all_page_elements = page_analyzer.analyze || []
55
+ best_candidate_analysis = Analyzer.perform_advanced_analysis(failed_info, all_page_elements, platform) rescue nil
56
+
57
+ # --- SUA REGRA DE NEGÓCIO INTEGRADA AQUI ---
58
+ target_node = nil
59
+ if best_candidate_analysis && best_candidate_analysis[:attributes] && (path = best_candidate_analysis[:attributes][:path])
60
+ # Se encontrou um candidato, ele é o alvo para a XPathFactory
61
+ target_node = doc.at_xpath(path)
62
+ else
63
+ # Se NÃO encontrou, o alvo é o próprio elemento que falhou
93
64
  failed_attrs = parse_attrs_from_locator_string(failed_info[:selector_value] || '')
94
- end
95
-
96
- if failed_attrs && !failed_attrs.empty?
97
- temp_doc = Nokogiri::XML::Document.new
98
- tag = (failed_attrs.delete('tag') || failed_attrs.delete(:tag) || 'element').to_s
99
- target_node = Nokogiri::XML::Node.new(tag, temp_doc)
100
- failed_attrs.each { |k, v| target_node[k.to_s] = v.to_s unless k.to_s == 'tag' }
101
- alternative_xpaths = XPathFactory.generate_for_node(target_node) || []
102
- end
103
- else
104
- # se encontrou candidato, tenta gerar alternativas a partir do node encontrado
105
- if best_candidate_analysis[:attributes] && (path = best_candidate_analysis[:attributes][:path])
106
- begin
107
- doc = Nokogiri::XML(page_source) unless defined?(doc) && doc
108
- target_node = doc.at_xpath(path) rescue nil
109
- alternative_xpaths = XPathFactory.generate_for_node(target_node) if target_node
110
- rescue
111
- # ignore, já temos best_candidate_analysis
65
+ if !failed_attrs.empty?
66
+ temp_doc = Nokogiri::XML::Document.new
67
+ tag = (failed_attrs.delete('tag') || 'element').to_s
68
+ target_node = Nokogiri::XML::Node.new(tag, temp_doc)
69
+ failed_attrs.each { |k, v| target_node[k.to_s] = v.to_s }
112
70
  end
113
71
  end
72
+
73
+ # Gera as estratégias para o nó alvo, seja ele real ou "fantasma"
74
+ alternative_xpaths = XPathFactory.generate_for_node(target_node) if target_node
75
+ # -----------------------------------------------
114
76
  end
115
77
 
116
78
  report_data.merge!({
@@ -1,3 +1,3 @@
1
1
  module AppiumFailureHelper
2
- VERSION = "1.10.1"
2
+ VERSION = "1.10.2"
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.10.1
4
+ version: 1.10.2
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-07 00:00:00.000000000 Z
11
+ date: 2025-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri