appium_failure_helper 1.12.0 → 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: b6b283db967a4490c24e0ade301e6208c68ddb52a3d7193f3ec0cbc195b6b7f7
4
- data.tar.gz: d6e310dbd4764348b4906c734e7e46b7a08149aee8047e89bf9a422c7494f36a
3
+ metadata.gz: 28303c5b227b98d8c4d3ace598ada0f314bfb0506c1b83c91c581f2c91f758ec
4
+ data.tar.gz: cd8a27134421f9f1f0491124eeee51c3610e582efd8fcf6ab3a4f4917820deb6
5
5
  SHA512:
6
- metadata.gz: 9d9452cac6dafeb72445772d791bc5da79596ebaee7530aabd5339fb0548a64b718c020ae7c285f3846b042d6beb8eadc3631652b8f0e0c996663927aff8fe1e
7
- data.tar.gz: e249e9b3a468193c689e26cac719bd9e81a720fdea7a13bbfa5cc5e9e2cbbcc1da10363adbd51f9ff8bcdab3611d59f274b5984597db4dc76fa0ce0a859ef162
6
+ metadata.gz: c528dbf20a0234c0e64413b4f532bf97a077330a54547bc74517e06d44b8135269bb7c35ed7e5bdd8fdd07420a57877fe9f2f5cf6931655e8d7ccb80ed19b4f1
7
+ data.tar.gz: 468e0209d8dd6318571bd9ffc36fa3c53bdcca929648775d55bd1b187ea4c6bf4ae063923a7b87ca9da0fb9ed1af7e5cd797c75add7d75f88234f2ad660dc662
@@ -1,22 +1,60 @@
1
- # lib/appium_failure_helper/source_code_analyzer.rb
2
1
  module AppiumFailureHelper
3
2
  module SourceCodeAnalyzer
4
- # VERSÃO 4.0: Padrões de Regex corrigidos e muito mais robustos
5
- PATTERNS = [
6
- # Padrão 1: find_element(id: 'valor') ou find_element(:id => 'valor')
7
- # A correção chave é o \s* (espaço opcional) depois do nome do atributo.
8
- { type: 'id', regex: /(?:\$driver\.)?find_element\((?:id:\s*|:id\s*=>\s*)['"]([^'"]+)['"]\)/ },
9
- { type: 'xpath', regex: /(?:\$driver\.)?find_element\((?:xpath:\s*|:xpath\s*=>\s*)['"]([^'"]+)['"]\)/ },
10
- { type: 'accessibility_id', regex: /(?:\$driver\.)?find_element\((?:accessibility_id:\s*|:accessibility_id\s*=>\s*)['"]([^'"]+)['"]\)/ },
11
- { type: 'class_name', regex: /(?:\$driver\.)?find_element\((?:class_name:\s*|:class_name\s*=>\s*)['"]([^'"]+)['"]\)/ },
12
-
13
- # Padrão 2: find_element(:xpath, 'valor')
14
- { type: 'xpath', regex: /(?:\$driver\.)?find_element\(:xpath,\s*['"]([^'"]+)['"]\)/ },
15
-
16
- # Padrão 3: Helpers customizados como id('valor') ou xpath('valor')
17
- { type: 'id', regex: /(?:\$driver\.)?\s*id\s*\(?['"]([^'"]+)['"]\)?/ },
18
- { type: 'xpath', regex: /(?:\$driver\.)?\s*xpath\s*\(?['"]([^'"]+)['"]\)?/ }
19
- ].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
+
20
58
 
21
59
  def self.extract_from_exception(exception)
22
60
  # Busca a primeira linha do backtrace que seja um arquivo .rb do projeto
@@ -1,3 +1,3 @@
1
1
  module AppiumFailureHelper
2
- VERSION = "1.12.0"
2
+ VERSION = "1.13.0"
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.12.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Nascimento