appium_failure_helper 1.11.2 → 1.13.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: ca162ec556076926e93296faa53cf2c553519612c2ab5cdf1890fd3f309065f6
4
- data.tar.gz: cc2ccb70a0f1e20aff1b57107a89bc0cc9564812363bce6622099a24994ac135
3
+ metadata.gz: 28303c5b227b98d8c4d3ace598ada0f314bfb0506c1b83c91c581f2c91f758ec
4
+ data.tar.gz: cd8a27134421f9f1f0491124eeee51c3610e582efd8fcf6ab3a4f4917820deb6
5
5
  SHA512:
6
- metadata.gz: c9a273aa0f31aaeae0ec066a1e4cafb26369e767c725607ebe525d01be1b5571eef28f8989c3fba261f8fb4677d952767c80902e25d051e69f9d12288fb06951
7
- data.tar.gz: 17ffca0b9ba8bcc48c2ff2f228cf8051ee9ea04681240d544591a7fd60b714df134205c792e3ae508fa1affb700529a047362ecd1bc8f01a77b80c18c10faa60
6
+ metadata.gz: c528dbf20a0234c0e64413b4f532bf97a077330a54547bc74517e06d44b8135269bb7c35ed7e5bdd8fdd07420a57877fe9f2f5cf6931655e8d7ccb80ed19b4f1
7
+ data.tar.gz: 468e0209d8dd6318571bd9ffc36fa3c53bdcca929648775d55bd1b187ea4c6bf4ae063923a7b87ca9da0fb9ed1af7e5cd797c75add7d75f88234f2ad660dc662
@@ -1,21 +1,75 @@
1
- # lib/appium_failure_helper/source_code_analyzer.rb
2
1
  module AppiumFailureHelper
3
2
  module SourceCodeAnalyzer
4
- PATTERNS = [
5
- { type: 'id', regex: /(?:\$driver\.)?find_element\((?:id:|:id\s*=>)\s*['"]([^'"]+)['"]\)/ },
6
- { type: 'xpath', regex: /(?:\$driver\.)?find_element\((?:xpath:|:xpath\s*=>)\s*['"]([^'"]+)['"]\)/ },
7
- { type: 'id', regex: /(?:\$driver\.)?\s*id\s*\(?['"]([^'"]+)['"]\)?/ },
8
- { type: 'xpath', regex: /(?:\$driver\.)?\s*xpath\s*\(?['"]([^'"]+)['"]\)?/ }
9
- ].freeze
3
+ # VERSÃO 4.0: Padrões de Regex corrigidos e muito mais robustos
4
+ PATTERNS = [
5
+ # Padrão 1: find_element(id: 'valor') ou find_element(:id => 'valor')
6
+ { type: 'id', regex: /(?:\$driver\.)?find_element\((?:id:\s*|:id\s*=>\s*)['"]([^'"]+)['"]\)/ },
7
+ { type: 'xpath', regex: /(?:\$driver\.)?find_element\((?:xpath:\s*|:xpath\s*=>\s*)['"]([^'"]+)['"]\)/ },
8
+ { type: 'accessibility_id', regex: /(?:\$driver\.)?find_element\((?:accessibility_id:\s*|:accessibility_id\s*=>\s*)['"]([^'"]+)['"]\)/ },
9
+ { type: 'class_name', regex: /(?:\$driver\.)?find_element\((?:class_name:\s*|:class_name\s*=>\s*)['"]([^'"]+)['"]\)/ },
10
+
11
+ # Padrão 2: find_element(:xpath, 'valor') — forma comum em Appium
12
+ { type: 'xpath', regex: /(?:\$driver\.)?find_element\(:xpath,\s*['"]([^'"]+)['"]\)/ },
13
+ { type: 'id', regex: /(?:\$driver\.)?find_element\(:id,\s*['"]([^'"]+)['"]\)/ },
14
+
15
+ # Padrão 3: Helpers customizados — id('valor'), xpath('valor')
16
+ { type: 'id', regex: /(?:\$driver\.)?\s*id\s*\(?['"]([^'"]+)['"]\)?/ },
17
+ { type: 'xpath', regex: /(?:\$driver\.)?\s*xpath\s*\(?['"]([^'"]+)['"]\)?/ },
18
+
19
+ # Padrão 4: find_elements(...) — capturar listas de elementos
20
+ { type: 'id', regex: /(?:\$driver\.)?find_elements\((?:id:\s*|:id\s*=>\s*)['"]([^'"]+)['"]\)/ },
21
+ { type: 'xpath', regex: /(?:\$driver\.)?find_elements\((?:xpath:\s*|:xpath\s*=>\s*)['"]([^'"]+)['"]\)/ },
22
+ { type: 'class_name', regex: /(?:\$driver\.)?find_elements\((?:class_name:\s*|:class_name\s*=>\s*)['"]([^'"]+)['"]\)/ },
23
+
24
+ # Padrão 5: Uso direto do Appium::TouchAction (muito comum em mobile)
25
+ { type: 'tap', regex: /Appium::TouchAction\.new\.tap\(.*['"]([^'"]+)['"].*\)\.perform/ },
26
+
27
+ # Padrão 6: Elementos obtidos antes e usados depois
28
+ # Ex: el = $driver.find_element(:id, 'btn_ok')
29
+ { type: 'id', regex: /(\w+)\s*=\s*(?:\$driver\.)?find_element\(:id,\s*['"]([^'"]+)['"]\)/ },
30
+ { type: 'xpath', regex: /(\w+)\s*=\s*(?:\$driver\.)?find_element\(:xpath,\s*['"]([^'"]+)['"]\)/ },
31
+
32
+ # Padrão 7: Métodos customizados de Page Object
33
+ # Ex: login_button.click / campo_email.set 'valor'
34
+ { type: 'page_object', regex: /(\w+)\.(?:click|text|set|send_keys)\b/ },
35
+
36
+ # Padrão 8: Capybara (comum em projetos híbridos)
37
+ { type: 'capybara_css', regex: /find\(['"]([^'"]+)['"]\)/ },
38
+ { type: 'capybara_xpath', regex: /find\(:xpath,\s*['"]([^'"]+)['"]\)/ },
39
+ { type: 'capybara_id', regex: /find_by_id\(['"]([^'"]+)['"]\)/ },
40
+
41
+ # Padrão 9: By.new(:id, 'valor') — estilo Selenium puro
42
+ { type: 'id', regex: /By\.new\(:id,\s*['"]([^'"]+)['"]\)/ },
43
+ { type: 'xpath', regex: /By\.new\(:xpath,\s*['"]([^'"]+)['"]\)/ },
44
+
45
+ # Padrão 10: wait.until { ...find_element... }
46
+ { type: 'wait_id', regex: /wait\.until\s*\{.*find_element\(:id,\s*['"]([^'"]+)['"]\).*?\}/ },
47
+ { type: 'wait_xpath', regex: /wait\.until\s*\{.*find_element\(:xpath,\s*['"]([^'"]+)['"]\).*?\}/ },
48
+
49
+ # Padrão 11: find_element com variáveis dinâmicas
50
+ # Ex: find_element(:xpath, "//button[text()='#{btn_text}']")
51
+ { type: 'xpath_dynamic', regex: /find_element\(:xpath,\s*["'].*#\{[^}]+\}.*["']\)/ },
52
+
53
+ # Padrão 12: chamadas via helper no módulo ScreenObject
54
+ # Ex: element(:btn_login) { id 'login_button' }
55
+ { type: 'screenobject', regex: /element\(\s*:[^)]+\)\s*\{\s*(id|xpath)\s+['"]([^'"]+)['"]\s*\}/ }
56
+ ].freeze
57
+
10
58
 
11
59
  def self.extract_from_exception(exception)
60
+ # Busca a primeira linha do backtrace que seja um arquivo .rb do projeto
12
61
  location = exception.backtrace.find { |line| line.include?('.rb') && !line.include?('gems') }
13
62
  return {} unless location
63
+
64
+ # Usa o Regex que funciona em Windows e Unix para extrair caminho e linha
14
65
  path_match = location.match(/^(.*?):(\d+)(?::in.*)?$/)
15
66
  return {} unless path_match
67
+
16
68
  file_path, line_number = path_match.captures
17
69
  return {} unless File.exist?(file_path)
70
+
18
71
  begin
72
+ # Lê a linha exata onde o erro ocorreu
19
73
  error_line = File.readlines(file_path)[line_number.to_i - 1]
20
74
  return parse_line_for_locator(error_line)
21
75
  rescue
@@ -1,3 +1,3 @@
1
1
  module AppiumFailureHelper
2
- VERSION = "1.11.2"
2
+ VERSION = "1.13.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.11.2
4
+ version: 1.13.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-11-07 00:00:00.000000000 Z
11
+ date: 2025-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri