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 +4 -4
- data/lib/appium_failure_helper/handler.rb +26 -64
- data/lib/appium_failure_helper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e3447e2fe35beca0103d353b7af1c813ff9156fefc2d9136f5f994657d89618
|
4
|
+
data.tar.gz: 995aa92585cc7ef2a77b01f7525087afca3fec4210ad31e06cb5c0369654f5a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
51
|
-
|
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
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
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!({
|
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.
|
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-
|
11
|
+
date: 2025-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|