movva-tech-library 0.1.0__tar.gz

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.
Files changed (158) hide show
  1. movva_tech_library-0.1.0/PKG-INFO +132 -0
  2. movva_tech_library-0.1.0/README.md +110 -0
  3. movva_tech_library-0.1.0/pyproject.toml +25 -0
  4. movva_tech_library-0.1.0/setup.cfg +4 -0
  5. movva_tech_library-0.1.0/src/movva_tech_library/__init__.py +38 -0
  6. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/__init__.py +3 -0
  7. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/browserComponent.py +333 -0
  8. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/__init__.py +51 -0
  9. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/backCommand.py +13 -0
  10. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/clickCommand.py +19 -0
  11. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/closeTabCommand.py +13 -0
  12. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/doubleClickCommand.py +19 -0
  13. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/executeScriptCommand.py +19 -0
  14. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/findElementsCommand.py +19 -0
  15. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/forwardCommand.py +13 -0
  16. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/getAttributeCommand.py +23 -0
  17. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/getCurrentUrlCommand.py +13 -0
  18. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/getPageSourceCommand.py +13 -0
  19. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/getTabsCommand.py +13 -0
  20. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/getTextCommand.py +19 -0
  21. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/getTitleCommand.py +13 -0
  22. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/hoverCommand.py +19 -0
  23. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/navigateCommand.py +18 -0
  24. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/newTabCommand.py +14 -0
  25. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/pressKeyCommand.py +18 -0
  26. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/refreshCommand.py +13 -0
  27. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/screenshotCommand.py +18 -0
  28. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/selectDropdownCommand.py +32 -0
  29. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/switchToTabCommand.py +14 -0
  30. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/typeTextCommand.py +21 -0
  31. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/waitCommand.py +19 -0
  32. movva_tech_library-0.1.0/src/movva_tech_library/components/browser/commands/waitForElementCommand.py +22 -0
  33. movva_tech_library-0.1.0/src/movva_tech_library/components/email/commands/__init__.py +19 -0
  34. movva_tech_library-0.1.0/src/movva_tech_library/components/email/commands/configureEmailCommand.py +37 -0
  35. movva_tech_library-0.1.0/src/movva_tech_library/components/email/commands/deleteEmailCommand.py +52 -0
  36. movva_tech_library-0.1.0/src/movva_tech_library/components/email/commands/exportEmailCommand.py +54 -0
  37. movva_tech_library-0.1.0/src/movva_tech_library/components/email/commands/forwardEmailCommand.py +50 -0
  38. movva_tech_library-0.1.0/src/movva_tech_library/components/email/commands/moveEmailCommand.py +35 -0
  39. movva_tech_library-0.1.0/src/movva_tech_library/components/email/commands/readConditionsCommand.py +71 -0
  40. movva_tech_library-0.1.0/src/movva_tech_library/components/email/commands/readEmailCommand.py +46 -0
  41. movva_tech_library-0.1.0/src/movva_tech_library/components/email/commands/sendEmailCommand.py +50 -0
  42. movva_tech_library-0.1.0/src/movva_tech_library/components/email/emailComponent.py +353 -0
  43. movva_tech_library-0.1.0/src/movva_tech_library/components/general/general.py +3 -0
  44. movva_tech_library-0.1.0/src/movva_tech_library/components/grid/__init__.py +3 -0
  45. movva_tech_library-0.1.0/src/movva_tech_library/components/grid/commands/__init__.py +9 -0
  46. movva_tech_library-0.1.0/src/movva_tech_library/components/grid/commands/deleteRowCommand.py +40 -0
  47. movva_tech_library-0.1.0/src/movva_tech_library/components/grid/commands/getDataCommand.py +36 -0
  48. movva_tech_library-0.1.0/src/movva_tech_library/components/grid/commands/insertRowCommand.py +40 -0
  49. movva_tech_library-0.1.0/src/movva_tech_library/components/grid/gridComponent.py +68 -0
  50. movva_tech_library-0.1.0/src/movva_tech_library/components/http/__init__.py +3 -0
  51. movva_tech_library-0.1.0/src/movva_tech_library/components/http/commands/__init__.py +13 -0
  52. movva_tech_library-0.1.0/src/movva_tech_library/components/http/commands/deleteCommand.py +42 -0
  53. movva_tech_library-0.1.0/src/movva_tech_library/components/http/commands/getCommand.py +43 -0
  54. movva_tech_library-0.1.0/src/movva_tech_library/components/http/commands/patchCommand.py +44 -0
  55. movva_tech_library-0.1.0/src/movva_tech_library/components/http/commands/postCommand.py +44 -0
  56. movva_tech_library-0.1.0/src/movva_tech_library/components/http/commands/putCommand.py +44 -0
  57. movva_tech_library-0.1.0/src/movva_tech_library/components/http/httpComponent.py +139 -0
  58. movva_tech_library-0.1.0/src/movva_tech_library/components/orchestrator/__init__.py +3 -0
  59. movva_tech_library-0.1.0/src/movva_tech_library/components/orchestrator/commands/__init__.py +5 -0
  60. movva_tech_library-0.1.0/src/movva_tech_library/components/orchestrator/commands/authenticateCommand.py +45 -0
  61. movva_tech_library-0.1.0/src/movva_tech_library/components/orchestrator/orchestratorComponent.py +32 -0
  62. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/__init__.py +3 -0
  63. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/__init__.py +31 -0
  64. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/clickByImageCommand.py +66 -0
  65. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/clickByLocatorCommand.py +38 -0
  66. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/connectApplicationCommand.py +53 -0
  67. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/doubleClickByLocatorCommand.py +26 -0
  68. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/getTextCommand.py +36 -0
  69. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/hotkeyCommand.py +34 -0
  70. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/killCommand.py +27 -0
  71. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/pressKeyCommand.py +36 -0
  72. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/setActiveWindowCommand.py +57 -0
  73. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/startApplicationCommand.py +40 -0
  74. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/typeTextCommand.py +51 -0
  75. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/waitCommand.py +34 -0
  76. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/waitForImageCommand.py +52 -0
  77. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/commands/waitForWindowCommand.py +60 -0
  78. movva_tech_library-0.1.0/src/movva_tech_library/components/windows/windowsComponent.py +234 -0
  79. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/__init__.py +3 -0
  80. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/__init__.py +77 -0
  81. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/addChartCommand.py +63 -0
  82. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/autoFitColumnCommand.py +46 -0
  83. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/clearFiltersCommand.py +33 -0
  84. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/clearFormattingCommand.py +56 -0
  85. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/clearSheetCommand.py +35 -0
  86. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/closeSpreadsheetCommand.py +36 -0
  87. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/conditionalFormattingCommand.py +46 -0
  88. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/createMacroCommand.py +62 -0
  89. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/createSpreadsheetCommand.py +37 -0
  90. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/deleteColumnCommand.py +39 -0
  91. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/deleteRowCommand.py +39 -0
  92. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/duplicateSheetCommand.py +41 -0
  93. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/executeMacroCommand.py +53 -0
  94. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/exportToCsvCommand.py +42 -0
  95. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/exportToPdfCommand.py +55 -0
  96. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/filterColumnCommand.py +41 -0
  97. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/findFirstUsedRowCommand.py +34 -0
  98. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/findLastUsedRowCommand.py +34 -0
  99. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/formatCellCommand.py +77 -0
  100. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/formatCellCustomCommand.py +71 -0
  101. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/freezeHeaderCommand.py +36 -0
  102. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/insertColumnCommand.py +35 -0
  103. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/insertFormulaCommand.py +35 -0
  104. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/insertRowCommand.py +35 -0
  105. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/insertSheetCommand.py +35 -0
  106. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/openSpreadsheetCommand.py +38 -0
  107. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/readDataCommand.py +45 -0
  108. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/removeDuplicatesCommand.py +47 -0
  109. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/saveAsCommand.py +36 -0
  110. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/saveSpreadsheetCommand.py +34 -0
  111. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/searchValueCommand.py +39 -0
  112. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/selectCellsCommand.py +44 -0
  113. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/selectSheetCommand.py +35 -0
  114. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/sortColumnsCommand.py +41 -0
  115. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/toggleGridlinesCommand.py +34 -0
  116. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/writeCellCommand.py +35 -0
  117. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/commands/writeCellsCommand.py +35 -0
  118. movva_tech_library-0.1.0/src/movva_tech_library/components/worksheet/worksheetComponent.py +550 -0
  119. movva_tech_library-0.1.0/src/movva_tech_library/core/__init__.py +5 -0
  120. movva_tech_library-0.1.0/src/movva_tech_library/core/command/baseCommand.py +81 -0
  121. movva_tech_library-0.1.0/src/movva_tech_library/core/error/__init__.py +7 -0
  122. movva_tech_library-0.1.0/src/movva_tech_library/core/error/baseError.py +42 -0
  123. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/browser/__init__.py +7 -0
  124. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/browser/browserLibrary.py +111 -0
  125. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/browser/error/__init__.py +17 -0
  126. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/browser/error/browserEmptySelectionError.py +14 -0
  127. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/browser/error/browserImportError.py +14 -0
  128. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/browser/error/browserInvalidKeyError.py +14 -0
  129. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/browser/error/browserInvalidLocatorError.py +14 -0
  130. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/browser/error/browserNotSupportedError.py +14 -0
  131. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/browser/error/browserTabOutOfBoundsError.py +14 -0
  132. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/email/__init__.py +8 -0
  133. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/email/emailLibrary.py +212 -0
  134. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/email/error/__init__.py +13 -0
  135. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/email/error/emailAttachmentError.py +10 -0
  136. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/email/error/emailConfigurationError.py +10 -0
  137. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/email/error/emailConnectionError.py +10 -0
  138. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/email/error/emailProtocolError.py +10 -0
  139. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/grid/gridLibrary.py +18 -0
  140. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/http/httpLibrary.py +26 -0
  141. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/orchestrator/orchestratorLibrary.py +9 -0
  142. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/windows/windowsLibrary.py +98 -0
  143. movva_tech_library-0.1.0/src/movva_tech_library/core/lib/worksheet/worksheetLibrary.py +187 -0
  144. movva_tech_library-0.1.0/src/movva_tech_library/core/log/__init__.py +8 -0
  145. movva_tech_library-0.1.0/src/movva_tech_library/core/log/logConfig.py +93 -0
  146. movva_tech_library-0.1.0/src/movva_tech_library/core/plugin/browser/__init__.py +7 -0
  147. movva_tech_library-0.1.0/src/movva_tech_library/core/plugin/browser/playwritePlugin.py +217 -0
  148. movva_tech_library-0.1.0/src/movva_tech_library/core/plugin/browser/seleniumPlugin.py +257 -0
  149. movva_tech_library-0.1.0/src/movva_tech_library/core/plugin/email/__init__.py +9 -0
  150. movva_tech_library-0.1.0/src/movva_tech_library/core/plugin/email/imapPlugin.py +274 -0
  151. movva_tech_library-0.1.0/src/movva_tech_library/core/plugin/email/pop3Plugin.py +141 -0
  152. movva_tech_library-0.1.0/src/movva_tech_library/core/plugin/email/smtpPlugin.py +132 -0
  153. movva_tech_library-0.1.0/src/movva_tech_library/core/plugin/email/utils.py +79 -0
  154. movva_tech_library-0.1.0/src/movva_tech_library.egg-info/PKG-INFO +132 -0
  155. movva_tech_library-0.1.0/src/movva_tech_library.egg-info/SOURCES.txt +156 -0
  156. movva_tech_library-0.1.0/src/movva_tech_library.egg-info/dependency_links.txt +1 -0
  157. movva_tech_library-0.1.0/src/movva_tech_library.egg-info/requires.txt +19 -0
  158. movva_tech_library-0.1.0/src/movva_tech_library.egg-info/top_level.txt +1 -0
@@ -0,0 +1,132 @@
1
+ Metadata-Version: 2.4
2
+ Name: movva-tech-library
3
+ Version: 0.1.0
4
+ Summary: Core library for movva tech aplications.
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: opencv-python>=4.5.0
8
+ Requires-Dist: pyautogui>=0.9.53
9
+ Requires-Dist: pywinauto>=0.6.8
10
+ Requires-Dist: numpy>=1.19.0
11
+ Requires-Dist: openpyxl>=3.1.2
12
+ Requires-Dist: pywin32>=306
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest; extra == "dev"
15
+ Provides-Extra: browser
16
+ Requires-Dist: selenium>=4.10.0; extra == "browser"
17
+ Requires-Dist: playwright>=1.40.0; extra == "browser"
18
+ Provides-Extra: browser-selenium
19
+ Requires-Dist: selenium>=4.10.0; extra == "browser-selenium"
20
+ Provides-Extra: browser-playwright
21
+ Requires-Dist: playwright>=1.40.0; extra == "browser-playwright"
22
+
23
+ # movva-tech-library
24
+
25
+ Uma biblioteca de automação desktop focada em Windows, encapsulando e simplificando as funcionalidades do `pywinauto` e `pyautogui`.
26
+
27
+ ## Como inicializar
28
+
29
+ Para utilizar a biblioteca, basta importar e instanciar a classe `DesktopRobot`:
30
+
31
+ ```python
32
+ from movva_tech_library import DesktopRobot
33
+ from pathlib import Path
34
+
35
+ # Instanciando o robô
36
+ robot = DesktopRobot()
37
+
38
+ ## Referência de Métodos
39
+
40
+ ### Gerenciamento de Aplicações e Janelas
41
+
42
+ - **Iniciar uma aplicação:**
43
+ ```python
44
+ robot.start_application(path=r"C:\Caminho\Para\App.exe", backend="uia")
45
+ ```
46
+
47
+ - **Conectar a uma aplicação em execução:**
48
+ ```python
49
+ robot.connect_application(title="Meu App", backend="uia")
50
+ ```
51
+
52
+ - **Esperar por uma janela específica:**
53
+ ```python
54
+ robot.wait_for_window(title="Janela Principal", timeout=10)
55
+ ```
56
+
57
+ - **Definir janela ativa:** (Útil para buscar locators apenas dentro dessa janela)
58
+ ```python
59
+ robot.set_active_window(title="Janela Principal")
60
+ ```
61
+
62
+ - **Encerrar aplicação:**
63
+ ```python
64
+ robot.kill()
65
+ ```
66
+
67
+ ### Interação com Elementos da Interface (Locators pywinauto)
68
+
69
+ Os métodos abaixo aceitam qualquer critério do `pywinauto` (ex: `title`, `auto_id`, `control_type`).
70
+
71
+ - **Clicar por locator:**
72
+ ```python
73
+ robot.click_by_locator(title="Botão Confirmar")
74
+ ```
75
+
76
+ - **Duplo clique por locator:**
77
+ ```python
78
+ robot.double_click_by_locator(auto_id="btnDetalhes")
79
+ ```
80
+
81
+ - **Obter texto de um elemento:**
82
+ ```python
83
+ texto = robot.get_text(auto_id="labelStatus")
84
+ print(texto)
85
+ ```
86
+
87
+ ### Interação por Imagens na Tela (pyautogui)
88
+
89
+ > Recomenda-se o uso de caminhos absolutos para as imagens.
90
+
91
+ - **Clicar em uma imagem:**
92
+ ```python
93
+ # Opcional: usar offset_x e offset_y para clicar deslocado do centro da imagem
94
+ image_path = str(BASE_DIR / "assets" / "botao.png")
95
+ robot.click_by_image(image_path, confidence=0.9, timeout=10)
96
+ ```
97
+
98
+ - **Esperar por uma imagem aparecer na tela:**
99
+ ```python
100
+ coordenadas = robot.wait_for_image(image_path, confidence=0.9, timeout=10)
101
+ ```
102
+
103
+ ### Teclado e Digitação
104
+
105
+ - **Digitar texto:**
106
+ Pode focar em um elemento específico antes de digitar caso forneça um `locator`.
107
+ ```python
108
+ # Digita livremente onde o cursor estiver
109
+ robot.type_text("Olá Mundo", interval=0.05)
110
+
111
+ # Foca no input primeiro e depois digita
112
+ robot.type_text("Meu texto direto no campo", locator={"auto_id": "inputTexto"})
113
+ ```
114
+
115
+ - **Pressionar teclas isoladas:**
116
+ ```python
117
+ robot.press_key("enter")
118
+ robot.press_key("tab", presses=2)
119
+ ```
120
+
121
+ - **Pressionar atalhos (hotkeys):**
122
+ ```python
123
+ robot.hotkey("ctrl", "c")
124
+ robot.hotkey("alt", "f4")
125
+ ```
126
+
127
+ ### Esperas (Timeouts e Pausas)
128
+
129
+ - **Pausa estática (não recomendado, use waits dinâmicos quando possível):**
130
+ ```python
131
+ robot.wait(2.5) # Aguarda 2.5 segundos
132
+ ```
@@ -0,0 +1,110 @@
1
+ # movva-tech-library
2
+
3
+ Uma biblioteca de automação desktop focada em Windows, encapsulando e simplificando as funcionalidades do `pywinauto` e `pyautogui`.
4
+
5
+ ## Como inicializar
6
+
7
+ Para utilizar a biblioteca, basta importar e instanciar a classe `DesktopRobot`:
8
+
9
+ ```python
10
+ from movva_tech_library import DesktopRobot
11
+ from pathlib import Path
12
+
13
+ # Instanciando o robô
14
+ robot = DesktopRobot()
15
+
16
+ ## Referência de Métodos
17
+
18
+ ### Gerenciamento de Aplicações e Janelas
19
+
20
+ - **Iniciar uma aplicação:**
21
+ ```python
22
+ robot.start_application(path=r"C:\Caminho\Para\App.exe", backend="uia")
23
+ ```
24
+
25
+ - **Conectar a uma aplicação em execução:**
26
+ ```python
27
+ robot.connect_application(title="Meu App", backend="uia")
28
+ ```
29
+
30
+ - **Esperar por uma janela específica:**
31
+ ```python
32
+ robot.wait_for_window(title="Janela Principal", timeout=10)
33
+ ```
34
+
35
+ - **Definir janela ativa:** (Útil para buscar locators apenas dentro dessa janela)
36
+ ```python
37
+ robot.set_active_window(title="Janela Principal")
38
+ ```
39
+
40
+ - **Encerrar aplicação:**
41
+ ```python
42
+ robot.kill()
43
+ ```
44
+
45
+ ### Interação com Elementos da Interface (Locators pywinauto)
46
+
47
+ Os métodos abaixo aceitam qualquer critério do `pywinauto` (ex: `title`, `auto_id`, `control_type`).
48
+
49
+ - **Clicar por locator:**
50
+ ```python
51
+ robot.click_by_locator(title="Botão Confirmar")
52
+ ```
53
+
54
+ - **Duplo clique por locator:**
55
+ ```python
56
+ robot.double_click_by_locator(auto_id="btnDetalhes")
57
+ ```
58
+
59
+ - **Obter texto de um elemento:**
60
+ ```python
61
+ texto = robot.get_text(auto_id="labelStatus")
62
+ print(texto)
63
+ ```
64
+
65
+ ### Interação por Imagens na Tela (pyautogui)
66
+
67
+ > Recomenda-se o uso de caminhos absolutos para as imagens.
68
+
69
+ - **Clicar em uma imagem:**
70
+ ```python
71
+ # Opcional: usar offset_x e offset_y para clicar deslocado do centro da imagem
72
+ image_path = str(BASE_DIR / "assets" / "botao.png")
73
+ robot.click_by_image(image_path, confidence=0.9, timeout=10)
74
+ ```
75
+
76
+ - **Esperar por uma imagem aparecer na tela:**
77
+ ```python
78
+ coordenadas = robot.wait_for_image(image_path, confidence=0.9, timeout=10)
79
+ ```
80
+
81
+ ### Teclado e Digitação
82
+
83
+ - **Digitar texto:**
84
+ Pode focar em um elemento específico antes de digitar caso forneça um `locator`.
85
+ ```python
86
+ # Digita livremente onde o cursor estiver
87
+ robot.type_text("Olá Mundo", interval=0.05)
88
+
89
+ # Foca no input primeiro e depois digita
90
+ robot.type_text("Meu texto direto no campo", locator={"auto_id": "inputTexto"})
91
+ ```
92
+
93
+ - **Pressionar teclas isoladas:**
94
+ ```python
95
+ robot.press_key("enter")
96
+ robot.press_key("tab", presses=2)
97
+ ```
98
+
99
+ - **Pressionar atalhos (hotkeys):**
100
+ ```python
101
+ robot.hotkey("ctrl", "c")
102
+ robot.hotkey("alt", "f4")
103
+ ```
104
+
105
+ ### Esperas (Timeouts e Pausas)
106
+
107
+ - **Pausa estática (não recomendado, use waits dinâmicos quando possível):**
108
+ ```python
109
+ robot.wait(2.5) # Aguarda 2.5 segundos
110
+ ```
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "movva-tech-library"
7
+ version = "0.1.0"
8
+ description = "Core library for movva tech aplications."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ dependencies = [
12
+ "opencv-python>=4.5.0",
13
+ "pyautogui>=0.9.53",
14
+ "pywinauto>=0.6.8",
15
+ "numpy>=1.19.0",
16
+ "openpyxl>=3.1.2",
17
+ "pywin32>=306",
18
+ ]
19
+
20
+
21
+ [project.optional-dependencies]
22
+ dev = ["pytest"]
23
+ browser = ["selenium>=4.10.0", "playwright>=1.40.0"]
24
+ browser-selenium = ["selenium>=4.10.0"]
25
+ browser-playwright = ["playwright>=1.40.0"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,38 @@
1
+ # __init__.py
2
+
3
+ from .components.general.general import saudacao
4
+ from .components.orchestrator.orchestratorComponent import OrchestratorComponent
5
+ from .components.grid.gridComponent import GridComponent
6
+ from .components.http.httpComponent import HttpComponent
7
+ from .components.windows.windowsComponent import WindowsComponent
8
+ from .components.email.emailComponent import EmailComponent, EmailWrapper
9
+ from .components.browser.browserComponent import Browser
10
+ from .components.worksheet.worksheetComponent import WorksheetComponent
11
+
12
+ # Backward compatibility aliases
13
+ Orchestrator = OrchestratorComponent
14
+ HttpRequest = HttpComponent
15
+ Grid = GridComponent
16
+ DesktopRobot = WindowsComponent
17
+ SpreadsheetWrapper = WorksheetComponent
18
+ BrowserComponent = Browser
19
+
20
+ __all__ = [
21
+ 'saudacao',
22
+ 'OrchestratorComponent',
23
+ 'Orchestrator',
24
+ 'HttpComponent',
25
+ 'HttpRequest',
26
+ 'GridComponent',
27
+ 'Grid',
28
+ 'WindowsComponent',
29
+ 'DesktopRobot',
30
+ 'EmailComponent',
31
+ 'EmailWrapper',
32
+ 'Browser',
33
+ 'BrowserComponent',
34
+ 'WorksheetComponent',
35
+ 'SpreadsheetWrapper',
36
+ ]
37
+
38
+ __version__ = '1.0.0'
@@ -0,0 +1,3 @@
1
+ from .browser import Browser
2
+
3
+ __all__ = ['Browser']
@@ -0,0 +1,333 @@
1
+ import os
2
+ import time
3
+ from typing import Any, Dict, List, Optional, Union
4
+
5
+ from movva_tech_library.core.lib.browser import _BrowserLibrary, _BrowserPlugin
6
+ from movva_tech_library.core.plugin.browser import _SeleniumPlugin, _PlaywrightPlugin
7
+
8
+ from .commands import (
9
+ NavigateCommand,
10
+ BackCommand,
11
+ ForwardCommand,
12
+ RefreshCommand,
13
+ ClickCommand,
14
+ DoubleClickCommand,
15
+ TypeTextCommand,
16
+ HoverCommand,
17
+ PressKeyCommand,
18
+ GetTextCommand,
19
+ GetAttributeCommand,
20
+ GetCurrentUrlCommand,
21
+ GetPageSourceCommand,
22
+ GetTitleCommand,
23
+ WaitForElementCommand,
24
+ WaitCommand,
25
+ FindElementsCommand,
26
+ SelectDropdownCommand,
27
+ NewTabCommand,
28
+ SwitchToTabCommand,
29
+ CloseTabCommand,
30
+ GetTabsCommand,
31
+ ExecuteScriptCommand,
32
+ ScreenshotCommand,
33
+ )
34
+
35
+
36
+ class Browser(_BrowserLibrary) :
37
+ """
38
+ Wrapper unificado de automação web com suporte a Selenium e Playwright.
39
+
40
+ Permite escolher o engine de automação no construtor e expõe uma API
41
+ consistente independente do backend selecionado.
42
+
43
+ Engines suportados: 'selenium', 'playwright'
44
+ Browsers suportados: 'chrome', 'firefox', 'edge'
45
+
46
+ Exemplo de uso:
47
+ browser = Browser(engine='selenium', browser='chrome', headless=True)
48
+ browser.navigate('https://example.com')
49
+ browser.click('#botao', by='css')
50
+ browser.close()
51
+
52
+ Nota (Playwright): Após instalar o pacote, execute `playwright install`
53
+ para baixar os binários dos browsers.
54
+ """
55
+
56
+ def __init__(
57
+ self,
58
+ engine: str = 'selenium',
59
+ browser: str = 'chrome',
60
+ headless: bool = False,
61
+ timeout: float = 10,
62
+ ):
63
+ """
64
+ Inicializa o Browser com o engine e browser especificados.
65
+
66
+ Args:
67
+ engine: Engine de automação — 'selenium' ou 'playwright'.
68
+ browser: Navegador a usar — 'chrome', 'firefox' ou 'edge'.
69
+ headless: Se True, executa o browser sem interface gráfica.
70
+ timeout: Tempo padrão de espera (em segundos) para localizar elementos.
71
+ """
72
+ engine = engine.lower()
73
+ if engine == 'selenium':
74
+ self._driver: _BrowserPlugin = _SeleniumPlugin(browser, headless, timeout)
75
+ elif engine == 'playwright':
76
+ self._driver: _BrowserPlugin = _PlaywrightPlugin(browser, headless, timeout)
77
+ else:
78
+ raise ValueError(
79
+ f"Engine '{engine}' não suportado. Use 'selenium' ou 'playwright'."
80
+ )
81
+
82
+ self._engine = engine
83
+ self._timeout = timeout
84
+
85
+ # region Navegação
86
+
87
+ def navigate(self, url: str):
88
+ """Navegar para uma URL."""
89
+ return NavigateCommand(self, url).run()
90
+
91
+ def back(self):
92
+ """Voltar para a página anterior no histórico."""
93
+ return BackCommand(self).run()
94
+
95
+ def forward(self):
96
+ """Avançar para a próxima página no histórico."""
97
+ return ForwardCommand(self).run()
98
+
99
+ def refresh(self):
100
+ """Recarregar a página atual."""
101
+ return RefreshCommand(self).run()
102
+ # endregion
103
+
104
+ # region Interação
105
+
106
+ def click(self, selector: str, by: str = 'css'):
107
+ """Clicar em um elemento da página.
108
+
109
+ Args:
110
+ selector: Seletor do elemento (ex: '#btn', '//button[@id="ok"]').
111
+ by: Tipo de localizador — 'css', 'xpath', 'id', 'name', 'class', 'tag'.
112
+ """
113
+ return ClickCommand(self, selector, by).run()
114
+
115
+ def double_click(self, selector: str, by: str = 'css'):
116
+ """Clicar duas vezes (double click) em um elemento da página.
117
+
118
+ Args:
119
+ selector: Seletor do elemento.
120
+ by: Tipo de localizador — 'css', 'xpath', 'id', 'name', 'class', 'tag'.
121
+ """
122
+ return DoubleClickCommand(self, selector, by).run()
123
+
124
+ def type_text(self, selector: str, text: str, by: str = 'css', clear: bool = True):
125
+ """Digitar texto em um campo de entrada (input/textarea).
126
+
127
+ Args:
128
+ selector: Seletor do elemento.
129
+ text: Texto a ser digitado.
130
+ by: Tipo de localizador — 'css', 'xpath', 'id', 'name', 'class', 'tag'.
131
+ clear: Se True, limpa o campo antes de digitar. Default True.
132
+ """
133
+ return TypeTextCommand(self, selector, text, by, clear).run()
134
+
135
+ def hover(self, selector: str, by: str = 'css'):
136
+ """Passar o mouse sobre um elemento (hover).
137
+
138
+ Args:
139
+ selector: Seletor do elemento.
140
+ by: Tipo de localizador — 'css', 'xpath', 'id', 'name', 'class', 'tag'.
141
+ """
142
+ return HoverCommand(self, selector, by).run()
143
+
144
+ def press_key(self, key: str):
145
+ """Pressionar uma tecla do teclado.
146
+
147
+ Args:
148
+ key: Nome da tecla (ex: 'Enter', 'Tab', 'Escape', 'ArrowDown').
149
+ Selenium usa nomes como 'ENTER', 'TAB'. Playwright usa 'Enter', 'Tab'.
150
+ """
151
+ return PressKeyCommand(self, key).run()
152
+ # endregion
153
+
154
+ # region Leitura de Dados
155
+
156
+ def get_text(self, selector: str, by: str = 'css') -> str:
157
+ """Obter o texto visível de um elemento.
158
+
159
+ Args:
160
+ selector: Seletor do elemento.
161
+ by: Tipo de localizador — 'css', 'xpath', 'id', 'name', 'class', 'tag'.
162
+
163
+ Returns:
164
+ Texto interno do elemento.
165
+ """
166
+ return GetTextCommand(self, selector, by).run()
167
+
168
+ def get_attribute(self, selector: str, attribute: str, by: str = 'css') -> Optional[str]:
169
+ """Obter o valor de um atributo HTML de um elemento.
170
+
171
+ Args:
172
+ selector: Seletor do elemento.
173
+ attribute: Nome do atributo HTML (ex: 'href', 'src', 'value', 'data-id').
174
+ by: Tipo de localizador — 'css', 'xpath', 'id', 'name', 'class', 'tag'.
175
+
176
+ Returns:
177
+ Valor do atributo ou None se não existir.
178
+ """
179
+ return GetAttributeCommand(self, selector, attribute, by).run()
180
+
181
+ def get_current_url(self) -> str:
182
+ """Obter a URL atual da página."""
183
+ return GetCurrentUrlCommand(self).run()
184
+
185
+ def get_page_source(self) -> str:
186
+ """Obter o código-fonte HTML da página atual."""
187
+ return GetPageSourceCommand(self).run()
188
+
189
+ def get_title(self) -> str:
190
+ """Obter o título da página atual."""
191
+ return GetTitleCommand(self).run()
192
+ # endregion
193
+
194
+ # region Espera (Wait)
195
+
196
+ def wait_for_element(
197
+ self,
198
+ selector: str,
199
+ by: str = 'css',
200
+ timeout: float = None,
201
+ visible: bool = False,
202
+ ):
203
+ """Esperar até que um elemento esteja presente (ou visível) na página.
204
+
205
+ Args:
206
+ selector: Seletor do elemento.
207
+ by: Tipo de localizador — 'css', 'xpath', 'id', 'name', 'class', 'tag'.
208
+ timeout: Tempo máximo de espera em segundos. Usa o timeout padrão se None.
209
+ visible: Se True, espera o elemento estar visível. Se False, apenas presente no DOM.
210
+ """
211
+ return WaitForElementCommand(self, selector, by, timeout, visible).run()
212
+
213
+ def wait(self, seconds: float):
214
+ """Pausar a execução por um determinado número de segundos.
215
+
216
+ Args:
217
+ seconds: Tempo de espera em segundos.
218
+ """
219
+ return WaitCommand(self, seconds).run()
220
+ # endregion
221
+
222
+ # region Busca de Elementos
223
+
224
+ def find_elements(self, selector: str, by: str = 'css') -> List[Dict[str, Any]]:
225
+ """Buscar múltiplos elementos e retornar seus dados.
226
+
227
+ Args:
228
+ selector: Seletor dos elementos.
229
+ by: Tipo de localizador — 'css', 'xpath', 'id', 'name', 'class', 'tag'.
230
+
231
+ Returns:
232
+ Lista de dicionários com 'text', 'tag' e 'attributes' de cada elemento.
233
+ """
234
+ return FindElementsCommand(self, selector, by).run()
235
+ # endregion
236
+
237
+ # region Seleção (Dropdown / Select)
238
+
239
+ def select_dropdown(
240
+ self,
241
+ selector: str,
242
+ value: str = None,
243
+ text: str = None,
244
+ index: int = None,
245
+ by: str = 'css',
246
+ ):
247
+ """Selecionar uma opção em um elemento <select>.
248
+
249
+ Forneça apenas um dos parâmetros: value, text ou index.
250
+
251
+ Args:
252
+ selector: Seletor do elemento <select>.
253
+ value: Valor do atributo 'value' da opção.
254
+ text: Texto visível da opção.
255
+ index: Índice da opção (base 0).
256
+ by: Tipo de localizador — 'css', 'xpath', 'id', 'name', 'class', 'tag'.
257
+ """
258
+ return SelectDropdownCommand(self, selector, value, text, index, by).run()
259
+ # endregion
260
+
261
+ # region Gerenciamento de Abas
262
+
263
+ def new_tab(self, url: str = None):
264
+ """Abrir uma nova aba no browser.
265
+
266
+ Args:
267
+ url: URL opcional para navegar na nova aba.
268
+ """
269
+ return NewTabCommand(self, url).run()
270
+
271
+ def switch_to_tab(self, index: int):
272
+ """Trocar para uma aba pelo índice.
273
+
274
+ Args:
275
+ index: Índice da aba (base 0).
276
+ """
277
+ return SwitchToTabCommand(self, index).run()
278
+
279
+ def close_tab(self):
280
+ """Fechar a aba atual e voltar para a última aba disponível."""
281
+ return CloseTabCommand(self).run()
282
+
283
+ def get_tabs(self) -> List[str]:
284
+ """Listar as abas abertas.
285
+
286
+ Returns:
287
+ Selenium: lista de window handles.
288
+ Playwright: lista de URLs das páginas abertas.
289
+ """
290
+ return GetTabsCommand(self).run()
291
+ # endregion
292
+
293
+ # region JavaScript
294
+
295
+ def execute_script(self, script: str, *args) -> Any:
296
+ """Executar código JavaScript na página.
297
+
298
+ Args:
299
+ script: Código JavaScript a executar.
300
+ *args: Argumentos passados para o script.
301
+
302
+ Returns:
303
+ Valor retornado pela execução do script.
304
+ """
305
+ return ExecuteScriptCommand(self, script, *args).run()
306
+ # endregion
307
+
308
+ # region Captura de Tela
309
+
310
+ def screenshot(self, path: str):
311
+ """Capturar screenshot da página e salvar em arquivo.
312
+
313
+ Args:
314
+ path: Caminho do arquivo de imagem (ex: 'screenshots/pagina.png').
315
+ """
316
+ return ScreenshotCommand(self, path).run()
317
+ # endregion
318
+
319
+ # region Encerramento
320
+
321
+ def close(self):
322
+ """Fechar o browser e encerrar o driver/engine."""
323
+ self._driver.close()
324
+
325
+ def __enter__(self):
326
+ """Suporte a context manager (with statement)."""
327
+ return self
328
+
329
+ def __exit__(self, exc_type, exc_val, exc_tb):
330
+ """Fecha o browser automaticamente ao sair do bloco with."""
331
+ self.close()
332
+ return False
333
+ # endregion
@@ -0,0 +1,51 @@
1
+ from .NavigateCommand import NavigateCommand
2
+ from .BackCommand import BackCommand
3
+ from .ForwardCommand import ForwardCommand
4
+ from .RefreshCommand import RefreshCommand
5
+ from .ClickCommand import ClickCommand
6
+ from .DoubleClickCommand import DoubleClickCommand
7
+ from .TypeTextCommand import TypeTextCommand
8
+ from .HoverCommand import HoverCommand
9
+ from .PressKeyCommand import PressKeyCommand
10
+ from .GetTextCommand import GetTextCommand
11
+ from .GetAttributeCommand import GetAttributeCommand
12
+ from .GetCurrentUrlCommand import GetCurrentUrlCommand
13
+ from .GetPageSourceCommand import GetPageSourceCommand
14
+ from .GetTitleCommand import GetTitleCommand
15
+ from .WaitForElementCommand import WaitForElementCommand
16
+ from .WaitCommand import WaitCommand
17
+ from .FindElementsCommand import FindElementsCommand
18
+ from .SelectDropdownCommand import SelectDropdownCommand
19
+ from .NewTabCommand import NewTabCommand
20
+ from .SwitchToTabCommand import SwitchToTabCommand
21
+ from .CloseTabCommand import CloseTabCommand
22
+ from .GetTabsCommand import GetTabsCommand
23
+ from .ExecuteScriptCommand import ExecuteScriptCommand
24
+ from .ScreenshotCommand import ScreenshotCommand
25
+
26
+ __all__ = [
27
+ 'NavigateCommand',
28
+ 'BackCommand',
29
+ 'ForwardCommand',
30
+ 'RefreshCommand',
31
+ 'ClickCommand',
32
+ 'DoubleClickCommand',
33
+ 'TypeTextCommand',
34
+ 'HoverCommand',
35
+ 'PressKeyCommand',
36
+ 'GetTextCommand',
37
+ 'GetAttributeCommand',
38
+ 'GetCurrentUrlCommand',
39
+ 'GetPageSourceCommand',
40
+ 'GetTitleCommand',
41
+ 'WaitForElementCommand',
42
+ 'WaitCommand',
43
+ 'FindElementsCommand',
44
+ 'SelectDropdownCommand',
45
+ 'NewTabCommand',
46
+ 'SwitchToTabCommand',
47
+ 'CloseTabCommand',
48
+ 'GetTabsCommand',
49
+ 'ExecuteScriptCommand',
50
+ 'ScreenshotCommand',
51
+ ]