@silasfmartins/testhub 1.0.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.
- package/.github/copilot-instructions.md +520 -0
- package/biome.json +37 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +169 -0
- package/dist/scripts/consumer-postinstall.d.ts +15 -0
- package/dist/scripts/consumer-postinstall.js +785 -0
- package/dist/scripts/generate-docs.d.ts +16 -0
- package/dist/scripts/generate-docs.js +1363 -0
- package/dist/scripts/generate-index.d.ts +2 -0
- package/dist/scripts/generate-index.js +314 -0
- package/dist/scripts/init-api.d.ts +2 -0
- package/dist/scripts/init-api.js +525 -0
- package/dist/scripts/init-banco.d.ts +2 -0
- package/dist/scripts/init-banco.js +347 -0
- package/dist/scripts/init-frontend.d.ts +2 -0
- package/dist/scripts/init-frontend.js +627 -0
- package/dist/scripts/init-mobile.d.ts +2 -0
- package/dist/scripts/init-mobile.js +481 -0
- package/dist/scripts/init-scenarios.d.ts +2 -0
- package/dist/scripts/init-scenarios.js +846 -0
- package/dist/scripts/init-ssh.d.ts +2 -0
- package/dist/scripts/init-ssh.js +639 -0
- package/dist/scripts/package-versions.d.ts +57 -0
- package/dist/scripts/package-versions.js +768 -0
- package/dist/scripts/postinstall.d.ts +1 -0
- package/dist/scripts/postinstall.js +527 -0
- package/dist/scripts/robust-build.d.ts +7 -0
- package/dist/scripts/robust-build.js +88 -0
- package/dist/scripts/setup-local-packages.d.ts +31 -0
- package/dist/scripts/setup-local-packages.js +237 -0
- package/dist/scripts/smart-override.d.ts +2 -0
- package/dist/scripts/smart-override.js +1360 -0
- package/dist/scripts/sync-configs.d.ts +27 -0
- package/dist/scripts/sync-configs.js +248 -0
- package/dist/scripts/test-biome-parse.d.ts +5 -0
- package/dist/scripts/test-biome-parse.js +84 -0
- package/dist/scripts/ultracite-setup.d.ts +4 -0
- package/dist/scripts/ultracite-setup.js +310 -0
- package/dist/scripts/update-all-init-scripts.d.ts +2 -0
- package/dist/scripts/update-all-init-scripts.js +52 -0
- package/dist/scripts/update-biome-schema.d.ts +15 -0
- package/dist/scripts/update-biome-schema.js +124 -0
- package/dist/src/AutoCoreFacade.d.ts +145 -0
- package/dist/src/AutoCoreFacade.js +217 -0
- package/dist/src/api/ApiActions.d.ts +297 -0
- package/dist/src/api/ApiActions.js +1905 -0
- package/dist/src/api/Certificate.d.ts +60 -0
- package/dist/src/api/Certificate.js +79 -0
- package/dist/src/api/JsonResponse.d.ts +116 -0
- package/dist/src/api/JsonResponse.js +206 -0
- package/dist/src/appium/DeviceFarmViewer.d.ts +79 -0
- package/dist/src/appium/DeviceFarmViewer.js +1083 -0
- package/dist/src/appium/MobileActions.d.ts +347 -0
- package/dist/src/appium/MobileActions.js +1632 -0
- package/dist/src/appium/MobileConnection.d.ts +160 -0
- package/dist/src/appium/MobileConnection.js +772 -0
- package/dist/src/config/envLoader.d.ts +123 -0
- package/dist/src/config/envLoader.js +361 -0
- package/dist/src/config/jest-safe-setup.d.ts +19 -0
- package/dist/src/config/jest-safe-setup.js +369 -0
- package/dist/src/config/timeouts.d.ts +32 -0
- package/dist/src/config/timeouts.js +38 -0
- package/dist/src/desktop/DesktopActions.d.ts +46 -0
- package/dist/src/desktop/DesktopActions.js +398 -0
- package/dist/src/desktop/DesktopConnection.d.ts +32 -0
- package/dist/src/desktop/DesktopConnection.js +84 -0
- package/dist/src/domain/entities/TestExecution.d.ts +117 -0
- package/dist/src/domain/entities/TestExecution.js +150 -0
- package/dist/src/domain/entities/TestReport.d.ts +114 -0
- package/dist/src/domain/entities/TestReport.js +179 -0
- package/dist/src/domain/repositories/ITestRepository.d.ts +196 -0
- package/dist/src/domain/repositories/ITestRepository.js +14 -0
- package/dist/src/domain/schemas/ValidationSchemas.d.ts +159 -0
- package/dist/src/domain/schemas/ValidationSchemas.js +181 -0
- package/dist/src/functions/errors/BaseError.d.ts +78 -0
- package/dist/src/functions/errors/BaseError.js +245 -0
- package/dist/src/functions/errors/ConfigurationError.d.ts +16 -0
- package/dist/src/functions/errors/ConfigurationError.js +48 -0
- package/dist/src/functions/errors/ErrorCatalog.d.ts +148 -0
- package/dist/src/functions/errors/ErrorCatalog.js +157 -0
- package/dist/src/functions/errors/GlobalErrorHandler.d.ts +101 -0
- package/dist/src/functions/errors/GlobalErrorHandler.js +281 -0
- package/dist/src/functions/errors/IntegrationError.d.ts +17 -0
- package/dist/src/functions/errors/IntegrationError.js +51 -0
- package/dist/src/functions/errors/SecurityError.d.ts +14 -0
- package/dist/src/functions/errors/SecurityError.js +42 -0
- package/dist/src/functions/errors/SystemError.d.ts +12 -0
- package/dist/src/functions/errors/SystemError.js +36 -0
- package/dist/src/functions/errors/ValidationError.d.ts +14 -0
- package/dist/src/functions/errors/ValidationError.js +61 -0
- package/dist/src/functions/errors/index.d.ts +12 -0
- package/dist/src/functions/errors/index.js +13 -0
- package/dist/src/global-setup.d.ts +1 -0
- package/dist/src/global-setup.js +1037 -0
- package/dist/src/helpers/BancoActions.d.ts +188 -0
- package/dist/src/helpers/BancoActions.js +581 -0
- package/dist/src/helpers/EnviromentHelper.d.ts +17 -0
- package/dist/src/helpers/EnviromentHelper.js +66 -0
- package/dist/src/helpers/ParallelExecutionHelper.d.ts +183 -0
- package/dist/src/helpers/ParallelExecutionHelper.js +375 -0
- package/dist/src/helpers/SyncSignal.d.ts +15 -0
- package/dist/src/helpers/SyncSignal.js +44 -0
- package/dist/src/hubdocs/CategoryDetector.d.ts +83 -0
- package/dist/src/hubdocs/CategoryDetector.js +401 -0
- package/dist/src/hubdocs/DirectStatementInterceptor.d.ts +54 -0
- package/dist/src/hubdocs/DirectStatementInterceptor.js +243 -0
- package/dist/src/hubdocs/ExecutionTracker.d.ts +107 -0
- package/dist/src/hubdocs/ExecutionTracker.js +702 -0
- package/dist/src/hubdocs/HubDocs.d.ts +395 -0
- package/dist/src/hubdocs/HubDocs.js +3586 -0
- package/dist/src/hubdocs/StatementMethodFilter.d.ts +71 -0
- package/dist/src/hubdocs/StatementMethodFilter.js +618 -0
- package/dist/src/hubdocs/StatementTracker.d.ts +417 -0
- package/dist/src/hubdocs/StatementTracker.js +2419 -0
- package/dist/src/hubdocs/SwaggerGenerator.d.ts +59 -0
- package/dist/src/hubdocs/SwaggerGenerator.js +405 -0
- package/dist/src/hubdocs/index.d.ts +9 -0
- package/dist/src/hubdocs/index.js +9 -0
- package/dist/src/hubdocs/types.d.ts +114 -0
- package/dist/src/hubdocs/types.js +5 -0
- package/dist/src/infrastructure/DependencyContainer.d.ts +142 -0
- package/dist/src/infrastructure/DependencyContainer.js +250 -0
- package/dist/src/infrastructure/adapters/AppiumAdapter.d.ts +168 -0
- package/dist/src/infrastructure/adapters/AppiumAdapter.js +468 -0
- package/dist/src/infrastructure/adapters/OracleAdapter.d.ts +150 -0
- package/dist/src/infrastructure/adapters/OracleAdapter.js +388 -0
- package/dist/src/infrastructure/adapters/PlaywrightAdapter.d.ts +192 -0
- package/dist/src/infrastructure/adapters/PlaywrightAdapter.js +382 -0
- package/dist/src/infrastructure/adapters/SSHAdapter.d.ts +141 -0
- package/dist/src/infrastructure/adapters/SSHAdapter.js +428 -0
- package/dist/src/interfaces.d.ts +501 -0
- package/dist/src/interfaces.js +25 -0
- package/dist/src/internal/fakes/__fake-actions__.d.ts +17 -0
- package/dist/src/internal/fakes/__fake-actions__.js +21 -0
- package/dist/src/internal/fakes/__forbidden__.d.ts +10 -0
- package/dist/src/internal/fakes/__forbidden__.js +18 -0
- package/dist/src/internal/fakes/__honeypot__.d.ts +15 -0
- package/dist/src/internal/fakes/__honeypot__.js +24 -0
- package/dist/src/octane/OctaneReporter.d.ts +13 -0
- package/dist/src/octane/OctaneReporter.js +61 -0
- package/dist/src/playwright/CryptoActions.d.ts +20 -0
- package/dist/src/playwright/CryptoActions.js +75 -0
- package/dist/src/playwright/EnhancedWebActions.d.ts +7 -0
- package/dist/src/playwright/EnhancedWebActions.js +65 -0
- package/dist/src/playwright/WebActions.d.ts +1599 -0
- package/dist/src/playwright/WebActions.js +11788 -0
- package/dist/src/playwright/actions/ActionTimeline.d.ts +36 -0
- package/dist/src/playwright/actions/ActionTimeline.js +101 -0
- package/dist/src/playwright/actions/RecoveryQueue.d.ts +82 -0
- package/dist/src/playwright/actions/RecoveryQueue.js +130 -0
- package/dist/src/playwright/actions/SelectorCache.d.ts +53 -0
- package/dist/src/playwright/actions/SelectorCache.js +96 -0
- package/dist/src/playwright/actions/index.d.ts +13 -0
- package/dist/src/playwright/actions/index.js +14 -0
- package/dist/src/playwright/actions/types.d.ts +147 -0
- package/dist/src/playwright/actions/types.js +5 -0
- package/dist/src/playwright/fixtures.d.ts +112 -0
- package/dist/src/playwright/fixtures.js +718 -0
- package/dist/src/playwright/network-logs-reporter.d.ts +7 -0
- package/dist/src/playwright/network-logs-reporter.js +66 -0
- package/dist/src/playwright/registerRecoveryWrappers.d.ts +1 -0
- package/dist/src/playwright/registerRecoveryWrappers.js +54 -0
- package/dist/src/security/BuildSecurity.d.ts +12 -0
- package/dist/src/security/BuildSecurity.js +138 -0
- package/dist/src/security/EulaProtection.d.ts +70 -0
- package/dist/src/security/EulaProtection.js +155 -0
- package/dist/src/security/HoneypotManager.d.ts +46 -0
- package/dist/src/security/HoneypotManager.js +234 -0
- package/dist/src/security/KeysManager.d.ts +36 -0
- package/dist/src/security/KeysManager.js +158 -0
- package/dist/src/security/ProofOfWorkIntegration.d.ts +64 -0
- package/dist/src/security/ProofOfWorkIntegration.js +206 -0
- package/dist/src/security/SecurityValidation.d.ts +21 -0
- package/dist/src/security/SecurityValidation.js +163 -0
- package/dist/src/security/SourceMapProtection.d.ts +55 -0
- package/dist/src/security/SourceMapProtection.js +220 -0
- package/dist/src/security/protector.d.ts +1 -0
- package/dist/src/security/protector.js +97 -0
- package/dist/src/ssh/SSHActions.d.ts +262 -0
- package/dist/src/ssh/SSHActions.js +790 -0
- package/dist/src/ssh/SSHClient.d.ts +99 -0
- package/dist/src/ssh/SSHClient.js +409 -0
- package/dist/src/statements/BaseStatement.d.ts +38 -0
- package/dist/src/statements/BaseStatement.js +78 -0
- package/dist/src/testContext/AuthStateManager.d.ts +93 -0
- package/dist/src/testContext/AuthStateManager.js +256 -0
- package/dist/src/testContext/CoverageManager.d.ts +198 -0
- package/dist/src/testContext/CoverageManager.js +917 -0
- package/dist/src/testContext/TestAnnotations.d.ts +476 -0
- package/dist/src/testContext/TestAnnotations.js +2647 -0
- package/dist/src/testContext/TestContext.d.ts +138 -0
- package/dist/src/testContext/TestContext.js +369 -0
- package/dist/src/testContext/UnifiedHtmlGenerator.d.ts +7 -0
- package/dist/src/testContext/UnifiedHtmlGenerator.js +264 -0
- package/dist/src/testContext/UnifiedReportManager.d.ts +211 -0
- package/dist/src/testContext/UnifiedReportManager.js +1206 -0
- package/dist/src/testhub/DynamicConfigManager.d.ts +121 -0
- package/dist/src/testhub/DynamicConfigManager.js +320 -0
- package/dist/src/testhub/SystemsManager.d.ts +119 -0
- package/dist/src/testhub/SystemsManager.js +365 -0
- package/dist/src/testhub/TestHubClient.d.ts +335 -0
- package/dist/src/testhub/TestHubClient.js +1215 -0
- package/dist/src/testhub/TestHubReporter.d.ts +62 -0
- package/dist/src/testhub/TestHubReporter.js +576 -0
- package/dist/src/testhub/TestHubVars.d.ts +116 -0
- package/dist/src/testhub/TestHubVars.js +273 -0
- package/dist/src/utils/ActionInterceptor.d.ts +59 -0
- package/dist/src/utils/ActionInterceptor.js +741 -0
- package/dist/src/utils/ArtifactsCompressor.d.ts +43 -0
- package/dist/src/utils/ArtifactsCompressor.js +181 -0
- package/dist/src/utils/AutoLogsFinal.d.ts +47 -0
- package/dist/src/utils/AutoLogsFinal.js +148 -0
- package/dist/src/utils/CodeGenSession.d.ts +114 -0
- package/dist/src/utils/CodeGenSession.js +264 -0
- package/dist/src/utils/ConfigLogger.d.ts +133 -0
- package/dist/src/utils/ConfigLogger.js +611 -0
- package/dist/src/utils/CustomReporter.d.ts +22 -0
- package/dist/src/utils/CustomReporter.js +352 -0
- package/dist/src/utils/DataStore.d.ts +171 -0
- package/dist/src/utils/DataStore.js +484 -0
- package/dist/src/utils/DatabaseInterceptor.d.ts +19 -0
- package/dist/src/utils/DatabaseInterceptor.js +295 -0
- package/dist/src/utils/DateHelper.d.ts +16 -0
- package/dist/src/utils/DateHelper.js +120 -0
- package/dist/src/utils/DateValidator.d.ts +4 -0
- package/dist/src/utils/DateValidator.js +51 -0
- package/dist/src/utils/DocumentGenerator.d.ts +35 -0
- package/dist/src/utils/DocumentGenerator.js +129 -0
- package/dist/src/utils/EvidenceCapture.d.ts +90 -0
- package/dist/src/utils/EvidenceCapture.js +600 -0
- package/dist/src/utils/EvidenceReportGenerator.d.ts +70 -0
- package/dist/src/utils/EvidenceReportGenerator.js +799 -0
- package/dist/src/utils/FrameManagementUtil.d.ts +42 -0
- package/dist/src/utils/FrameManagementUtil.js +75 -0
- package/dist/src/utils/GlobalStatementsInterceptor.d.ts +1 -0
- package/dist/src/utils/GlobalStatementsInterceptor.js +1 -0
- package/dist/src/utils/HTMLTemplate.d.ts +1 -0
- package/dist/src/utils/HTMLTemplate.js +1034 -0
- package/dist/src/utils/InterceptacaoMagica.d.ts +23 -0
- package/dist/src/utils/InterceptacaoMagica.js +365 -0
- package/dist/src/utils/LogSanitizer.d.ts +35 -0
- package/dist/src/utils/LogSanitizer.js +110 -0
- package/dist/src/utils/Logger.d.ts +65 -0
- package/dist/src/utils/Logger.js +284 -0
- package/dist/src/utils/McpLocalClient.d.ts +141 -0
- package/dist/src/utils/McpLocalClient.js +871 -0
- package/dist/src/utils/PDFEvidenceGenerator.d.ts +20 -0
- package/dist/src/utils/PDFEvidenceGenerator.js +156 -0
- package/dist/src/utils/SpecFileAnalyzer.d.ts +35 -0
- package/dist/src/utils/SpecFileAnalyzer.js +209 -0
- package/dist/src/utils/StatementInterceptor.d.ts +18 -0
- package/dist/src/utils/StatementInterceptor.js +87 -0
- package/dist/src/utils/StatementLogger.d.ts +33 -0
- package/dist/src/utils/StatementLogger.js +113 -0
- package/dist/src/utils/StatementsInterceptor.d.ts +1 -0
- package/dist/src/utils/StatementsInterceptor.js +1 -0
- package/dist/src/utils/TeamsFlushHook.d.ts +17 -0
- package/dist/src/utils/TeamsFlushHook.js +168 -0
- package/dist/src/utils/TerminalLogCapture.d.ts +158 -0
- package/dist/src/utils/TerminalLogCapture.js +531 -0
- package/dist/src/utils/TestMethodLogger.d.ts +70 -0
- package/dist/src/utils/TestMethodLogger.js +95 -0
- package/dist/src/utils/UnifiedTeardown.d.ts +4 -0
- package/dist/src/utils/UnifiedTeardown.js +400 -0
- package/dist/src/utils/XPathCatalog.d.ts +152 -0
- package/dist/src/utils/XPathCatalog.js +350 -0
- package/dist/src/utils/generators.d.ts +90 -0
- package/dist/src/utils/generators.js +167 -0
- package/dist/src/utils/testRecovery/ResilientPlaywright.d.ts +152 -0
- package/dist/src/utils/testRecovery/ResilientPlaywright.js +715 -0
- package/dist/src/utils/testRecovery/TestRecoveryClient.d.ts +801 -0
- package/dist/src/utils/testRecovery/TestRecoveryClient.js +1415 -0
- package/dist/src/utils/testRecovery/autoFixCode.d.ts +65 -0
- package/dist/src/utils/testRecovery/autoFixCode.js +32 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +59 -0
- package/dist/wdio.conf.d.ts +1 -0
- package/dist/wdio.conf.js +420 -0
- package/package.json +137 -0
- package/protect-loader.mjs +643 -0
- package/scripts/consumer-postinstall.ts +975 -0
- package/scripts/generate-index.ts +343 -0
- package/scripts/init-api.ts +613 -0
- package/scripts/init-banco.ts +437 -0
- package/scripts/init-frontend.ts +727 -0
- package/scripts/init-mobile.ts +558 -0
- package/scripts/init-scenarios.ts +925 -0
- package/scripts/init-ssh.ts +734 -0
- package/scripts/package-versions.ts +978 -0
- package/scripts/postinstall.ts +605 -0
- package/scripts/smart-override.ts +1675 -0
- package/scripts/sync-configs.ts +302 -0
- package/scripts/ultracite-setup.ts +370 -0
- package/src/types/globals.d.ts +48 -0
- package/tsconfig.json +29 -0
- package/types/autocore-sync-signal.d.ts +10 -0
|
@@ -0,0 +1,1599 @@
|
|
|
1
|
+
import { type XPathCatalogItem, type CatalogGetOptions, type RawPageStructure } from "../utils/XPathCatalog.js";
|
|
2
|
+
import type { ILocator, IPage } from "../interfaces.js";
|
|
3
|
+
import { type DateOptions, type DateFormat } from "../utils/DateHelper.js";
|
|
4
|
+
export declare function invokeCodegen(params: any): Promise<void>;
|
|
5
|
+
import "../hubdocs/StatementTracker.js";
|
|
6
|
+
export type PageXPathItem = XPathCatalogItem;
|
|
7
|
+
type WaitVisibilityOptions = {
|
|
8
|
+
timeout?: number;
|
|
9
|
+
descricao?: string;
|
|
10
|
+
tirarPrint?: boolean;
|
|
11
|
+
};
|
|
12
|
+
type ExtendedWaitVisibilityOptions = WaitVisibilityOptions & {
|
|
13
|
+
hoverParent?: string;
|
|
14
|
+
checkOverlays?: boolean;
|
|
15
|
+
inFrameSelector?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Interface para log de Network (usado pelo startNetworkLogging/stopNetworkLogging)
|
|
19
|
+
*/
|
|
20
|
+
interface NetworkLogEntry {
|
|
21
|
+
timestamp: string;
|
|
22
|
+
type: "request" | "response" | "failed";
|
|
23
|
+
method: string;
|
|
24
|
+
url: string;
|
|
25
|
+
status?: number;
|
|
26
|
+
statusText?: string;
|
|
27
|
+
resourceType: string;
|
|
28
|
+
duration?: number;
|
|
29
|
+
size?: number;
|
|
30
|
+
errorText?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Classe de ações web para automação com Playwright.
|
|
34
|
+
* API nova e organizada seguindo padrão dos outros Actions (SSHActions, MobileActions, etc).
|
|
35
|
+
* Migrada de Actions.ts para nova arquitetura DDD.
|
|
36
|
+
*/
|
|
37
|
+
export declare class WebActions {
|
|
38
|
+
private static networkLoggingEnabled;
|
|
39
|
+
private static networkLogs;
|
|
40
|
+
private static networkRequestTimings;
|
|
41
|
+
private static networkListenersAttached;
|
|
42
|
+
/**
|
|
43
|
+
* ✅ NOVO: Extrai o seletor real de um ILocator ou string
|
|
44
|
+
* @private
|
|
45
|
+
* @param {string|ILocator} elemento Elemento do qual extrair o seletor
|
|
46
|
+
* @returns {string} O seletor extraído
|
|
47
|
+
*/
|
|
48
|
+
private static extractSelector;
|
|
49
|
+
/**
|
|
50
|
+
* ✅ NOVO: Detecta o tipo do seletor
|
|
51
|
+
* @private
|
|
52
|
+
* @param {string} selector Seletor a analisar
|
|
53
|
+
* @returns {string} Tipo do seletor
|
|
54
|
+
*/
|
|
55
|
+
private static detectSelectorType;
|
|
56
|
+
/**
|
|
57
|
+
* Timeout padrão para resolver XPath/locators entre contextos e frames.
|
|
58
|
+
*/
|
|
59
|
+
private static getResolveTimeoutMs;
|
|
60
|
+
/**
|
|
61
|
+
* Normaliza e simplifica eixos de XPath para versões equivalentes e mais estáveis.
|
|
62
|
+
*/
|
|
63
|
+
private static normalizeAxisXPath;
|
|
64
|
+
private static isXPathSelector;
|
|
65
|
+
/**
|
|
66
|
+
* Aguarda attachment e confirma match para reduzir falso negativo em DOM dinâmico.
|
|
67
|
+
*/
|
|
68
|
+
private static probeLocator;
|
|
69
|
+
/**
|
|
70
|
+
* Prioriza frames visíveis para busca de XPath.
|
|
71
|
+
*/
|
|
72
|
+
private static getFramesByVisibility;
|
|
73
|
+
/**
|
|
74
|
+
* Gera variações candidatas de um seletor para aumentar chances de localização
|
|
75
|
+
*/
|
|
76
|
+
private static getSelectorCandidates;
|
|
77
|
+
/**
|
|
78
|
+
* Retorna uma lista ampliada de seletores de contêineres de listas/dropdowns comuns
|
|
79
|
+
*/
|
|
80
|
+
private static getListSelectors;
|
|
81
|
+
/**
|
|
82
|
+
* Tenta clicar de forma robusta no locator: espera visibilidade, click normal, fallback para force, fallback evaluate click
|
|
83
|
+
*/
|
|
84
|
+
private static robustClick;
|
|
85
|
+
/**
|
|
86
|
+
* Normaliza seletor recebido em runtime para reduzir falhas por formatação.
|
|
87
|
+
*/
|
|
88
|
+
private static normalizeSelector;
|
|
89
|
+
/**
|
|
90
|
+
* Retorna locator singular quando houver múltiplos matches (usa first()).
|
|
91
|
+
*/
|
|
92
|
+
private static toSingleLocator;
|
|
93
|
+
/**
|
|
94
|
+
* Verifica se locator possui pelo menos um elemento.
|
|
95
|
+
*/
|
|
96
|
+
private static hasLocatorMatch;
|
|
97
|
+
/**
|
|
98
|
+
* Resolve locator em qualquer contexto disponível (page atual + iframes).
|
|
99
|
+
* Isso reduz falso negativo quando o usuário vê o elemento na tela, mas ele está em frame diferente.
|
|
100
|
+
*/
|
|
101
|
+
private static resolveLocatorAnyContext;
|
|
102
|
+
/**
|
|
103
|
+
* Resolve candidate usado no withRecovery sem perder fallback do Test Recovery.
|
|
104
|
+
*/
|
|
105
|
+
private static resolveCandidateForRecovery;
|
|
106
|
+
/**
|
|
107
|
+
* Fallback robusto para click, inclusive em elementos desabilitados/overlay.
|
|
108
|
+
*/
|
|
109
|
+
private static clickWithFallback;
|
|
110
|
+
/**
|
|
111
|
+
* Aguarda overlays/spinners/loadings comuns desaparecerem antes de interagir.
|
|
112
|
+
* Evita cliques que "funcionam" mas são interceptados por overlays.
|
|
113
|
+
*/
|
|
114
|
+
private static waitForOverlaysClear;
|
|
115
|
+
/**
|
|
116
|
+
* Verifica se o clique realmente teve efeito na página.
|
|
117
|
+
* Retorna true se houve mudança detectável (URL, DOM, rede).
|
|
118
|
+
* Usado para validar cliques via force:true ou dispatchEvent.
|
|
119
|
+
*/
|
|
120
|
+
private static verifyClickEffect;
|
|
121
|
+
/**
|
|
122
|
+
* Captura um snapshot leve do DOM para comparação pós-clique.
|
|
123
|
+
*/
|
|
124
|
+
private static captureDomSnapshot;
|
|
125
|
+
/**
|
|
126
|
+
* Fallback robusto para setar valor em inputs/textarea/contenteditable.
|
|
127
|
+
*/
|
|
128
|
+
private static setValueWithFallback;
|
|
129
|
+
/**
|
|
130
|
+
* Seleciona uma opção em um <select> comparando labels de forma normalizada
|
|
131
|
+
* (remove acentos, normaliza espaços e compara lowercase). Retorna true se selecionou.
|
|
132
|
+
* @private
|
|
133
|
+
*/
|
|
134
|
+
private static selectOptionByNormalizedLabel;
|
|
135
|
+
/**
|
|
136
|
+
* Retorna a primeira selector candidato que encontra elementos na página
|
|
137
|
+
*/
|
|
138
|
+
private static findFirstMatchingSelector;
|
|
139
|
+
/**
|
|
140
|
+
* 🆕 Extrai estrutura básica da página para o Test Recovery
|
|
141
|
+
* Captura botões, inputs, links e headings com seus seletores
|
|
142
|
+
* @param page Página do Playwright
|
|
143
|
+
* @returns Estrutura da página com elementos principais
|
|
144
|
+
*/
|
|
145
|
+
static extractBasicPageStructure(page: IPage): Promise<{
|
|
146
|
+
buttons?: Array<{
|
|
147
|
+
tag: string;
|
|
148
|
+
text: string;
|
|
149
|
+
xpath?: string;
|
|
150
|
+
id?: string;
|
|
151
|
+
className?: string;
|
|
152
|
+
}>;
|
|
153
|
+
inputs?: Array<{
|
|
154
|
+
tag: string;
|
|
155
|
+
type?: string;
|
|
156
|
+
xpath?: string;
|
|
157
|
+
id?: string;
|
|
158
|
+
name?: string;
|
|
159
|
+
placeholder?: string;
|
|
160
|
+
}>;
|
|
161
|
+
links?: Array<{
|
|
162
|
+
tag: string;
|
|
163
|
+
text: string;
|
|
164
|
+
href?: string;
|
|
165
|
+
xpath?: string;
|
|
166
|
+
}>;
|
|
167
|
+
headings?: Array<{
|
|
168
|
+
tag: string;
|
|
169
|
+
text: string;
|
|
170
|
+
xpath?: string;
|
|
171
|
+
}>;
|
|
172
|
+
}>;
|
|
173
|
+
/** Timestamp do último refreshDOM (debounce para evitar múltiplas chamadas consecutivas) */
|
|
174
|
+
private static _lastDOMRefreshTime;
|
|
175
|
+
/** Guard contra recursão infinita em withRecovery (click_other/navigateTo/switchTo dentro de recovery) */
|
|
176
|
+
private static _recoveryDepth;
|
|
177
|
+
private static readonly _maxRecoveryDepth;
|
|
178
|
+
/**
|
|
179
|
+
* 🔄 Força atualização/estabilização do DOM antes de localizar/interagir com elementos.
|
|
180
|
+
* Essencial para SPAs (ex.: Salesforce Lightning/Vlocity) que recriam Shadow DOM a cada interação.
|
|
181
|
+
*
|
|
182
|
+
* Chamado automaticamente ANTES de cada ação (click, setText, hover, etc.) para
|
|
183
|
+
* garantir que o DOM esteja sempre fresco na primeira tentativa.
|
|
184
|
+
*
|
|
185
|
+
* Estratégias:
|
|
186
|
+
* 1. waitForLoadState('domcontentloaded') — aguardar parsing base
|
|
187
|
+
* 2. Forçar reflow/repaint via JS (offsetHeight leitura)
|
|
188
|
+
* 3. Aguardar microtasks/pending mutations (requestAnimationFrame + setTimeout)
|
|
189
|
+
* 4. Aguardar Shadow DOM roots se estabilizarem (Custom Elements defineados)
|
|
190
|
+
* 5. Breve pausa para rendering assíncrono de frameworks (LWC, Aura, React)
|
|
191
|
+
*
|
|
192
|
+
* 🛡️ Debounce: pula automaticamente se chamado dentro do cooldown (default 200ms).
|
|
193
|
+
* 🛡️ Toggle: desabilitar com env AUTOCORE_REFRESH_DOM_BEFORE_ACTION=false
|
|
194
|
+
*
|
|
195
|
+
* @param {number} [stabilityMs=300] Tempo mínimo em ms para considerar o DOM estável.
|
|
196
|
+
*/
|
|
197
|
+
private static refreshDOM;
|
|
198
|
+
private static withRecovery;
|
|
199
|
+
private static applyValueHeuristics;
|
|
200
|
+
/**
|
|
201
|
+
* 🖼️ Obtém o locator correto considerando se estamos dentro de um iframe.
|
|
202
|
+
* Se switchTo foi chamado, usa o frameLocator para buscar elementos.
|
|
203
|
+
* @private
|
|
204
|
+
* @param {string | ILocator} elemento Seletor ou locator do elemento
|
|
205
|
+
* @returns {ILocator} Locator no contexto correto (page ou frame)
|
|
206
|
+
*/
|
|
207
|
+
private static getLocatorInContext;
|
|
208
|
+
/**
|
|
209
|
+
* 🖼️ Verifica se estamos dentro de um iframe.
|
|
210
|
+
* @returns {boolean} true se switchTo foi chamado e estamos em um frame
|
|
211
|
+
*/
|
|
212
|
+
static isInFrame(): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* 🖼️ Obtém o seletor do frame atual.
|
|
215
|
+
* @returns {string | null} Seletor do frame atual ou null se não estiver em um frame
|
|
216
|
+
*/
|
|
217
|
+
static getCurrentFrameSelector(): string | null;
|
|
218
|
+
static resolveWaitVisibilityOptions(timeoutOrOptions?: number | string | boolean | WaitVisibilityOptions, descricaoOrTirarPrint?: string | boolean, tirarPrintFallback?: boolean): Required<WaitVisibilityOptions>;
|
|
219
|
+
/**
|
|
220
|
+
* ✅ NOVO: Captura informações do stack trace para obter o nome do método
|
|
221
|
+
* @private
|
|
222
|
+
* @returns {string} Nome do método que chamou a ação
|
|
223
|
+
*/
|
|
224
|
+
private static getCallerMethodName;
|
|
225
|
+
/**
|
|
226
|
+
* ✅ NOVO: Função auxiliar para interceptar ações no AutoDocs
|
|
227
|
+
* @private
|
|
228
|
+
* @param {string} action Nome da ação (click, fill, hover, etc.)
|
|
229
|
+
* @param {string} [selector] Seletor do elemento (opcional)
|
|
230
|
+
* @param {string} [url] URL da página (opcional)
|
|
231
|
+
* @param {any} [extraDetails] Detalhes extras específicos da ação
|
|
232
|
+
*/
|
|
233
|
+
private static interceptForAutoDocs;
|
|
234
|
+
/**
|
|
235
|
+
* ✅ NOVO: Função auxiliar para atualizar status de sucesso no AutoDocs
|
|
236
|
+
* @private
|
|
237
|
+
* @param {string} action Nome da ação
|
|
238
|
+
* @param {string} [selector] Seletor do elemento (opcional)
|
|
239
|
+
* @param {boolean} success Se a ação foi bem-sucedida
|
|
240
|
+
* @param {number} duration Duração em ms
|
|
241
|
+
* @param {string} [error] Mensagem de erro (se houver)
|
|
242
|
+
*/
|
|
243
|
+
private static updateAutoDocsStatus;
|
|
244
|
+
/**
|
|
245
|
+
* Obtém a página atual do contexto de teste.
|
|
246
|
+
* @public
|
|
247
|
+
* @returns {IPage}
|
|
248
|
+
* @throws {Error} Se a página não estiver disponível.
|
|
249
|
+
*/
|
|
250
|
+
static getPage(): IPage;
|
|
251
|
+
/**
|
|
252
|
+
* 🆕 NOVO: Método para auto-inicializar o TestContext.page quando possível
|
|
253
|
+
* @param page Page do Playwright para inicializar automaticamente
|
|
254
|
+
*/
|
|
255
|
+
static ensurePageInitialized(page?: any): void;
|
|
256
|
+
/**
|
|
257
|
+
* Adiciona log ao UnifiedReportManager.
|
|
258
|
+
* @private
|
|
259
|
+
* @param {string} message Mensagem de log.
|
|
260
|
+
*/
|
|
261
|
+
private static logToUnified;
|
|
262
|
+
/**
|
|
263
|
+
* Registra metadados de ação no UnifiedReportManager.
|
|
264
|
+
* @private
|
|
265
|
+
* @param {string} actionType Tipo de ação.
|
|
266
|
+
* @param {boolean} success Sucesso da ação.
|
|
267
|
+
* @param {number} [duration] Duração em ms.
|
|
268
|
+
*/
|
|
269
|
+
private static addActionMetadata;
|
|
270
|
+
/**
|
|
271
|
+
* 📡 Inicia a captura de logs de Network no terminal.
|
|
272
|
+
* A partir deste ponto, todas as requisições/respostas serão logadas no terminal.
|
|
273
|
+
* Use `stopNetworkLogging()` para parar e gerar o resumo.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* await WebActions.startNetworkLogging()
|
|
278
|
+
* await WebActions.navigateTo('https://example.com')
|
|
279
|
+
* await WebActions.click('#button')
|
|
280
|
+
* const logs = await WebActions.stopNetworkLogging()
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
static startNetworkLogging(): Promise<void>;
|
|
284
|
+
/**
|
|
285
|
+
* 📡 Para a captura de logs de Network e exibe resumo no terminal.
|
|
286
|
+
*
|
|
287
|
+
* @returns {NetworkLogEntry[]} Array com todos os logs capturados
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* const logs = await WebActions.stopNetworkLogging()
|
|
292
|
+
* console.log(`Capturados ${logs.length} logs de rede`)
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
static stopNetworkLogging(): Promise<NetworkLogEntry[]>;
|
|
296
|
+
/**
|
|
297
|
+
* 📡 Retorna os logs de Network capturados até o momento (sem parar a captura).
|
|
298
|
+
*
|
|
299
|
+
* @returns {NetworkLogEntry[]} Array com logs capturados
|
|
300
|
+
*/
|
|
301
|
+
static getNetworkLogs(): NetworkLogEntry[];
|
|
302
|
+
/**
|
|
303
|
+
* 📡 Verifica se a captura de Network está ativa.
|
|
304
|
+
*/
|
|
305
|
+
static isNetworkLoggingEnabled(): boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Helper para truncar URLs longas nos logs de network
|
|
308
|
+
* @private
|
|
309
|
+
*/
|
|
310
|
+
private static truncateNetworkUrl;
|
|
311
|
+
/**
|
|
312
|
+
* Helper para formatar bytes de forma legível nos logs de network
|
|
313
|
+
* @private
|
|
314
|
+
*/
|
|
315
|
+
private static formatNetworkBytes;
|
|
316
|
+
/**
|
|
317
|
+
* 🌐 MELHORADO: Navega para uma URL com ErrorHandling completo e recuperação automática.
|
|
318
|
+
* @param {string} url URL de destino.
|
|
319
|
+
* @param {string} [descricao] Descrição da ação.
|
|
320
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
321
|
+
* @param {number} [tempo] Timeout em ms.
|
|
322
|
+
* @param {'load' | 'domcontentloaded' | 'networkidle' | 'commit'} [waitUntil] Estado de carregamento a esperar (default: 'networkidle').
|
|
323
|
+
*/
|
|
324
|
+
static navigateTo(url: string, descricao?: string, tirarPrint?: boolean, tempo?: number, waitUntil?: "load" | "domcontentloaded" | "networkidle" | "commit"): Promise<void>;
|
|
325
|
+
/**
|
|
326
|
+
* Preenche um campo/input.
|
|
327
|
+
* ✅ MELHORADO: Espera elemento estar visível antes de preencher.
|
|
328
|
+
*
|
|
329
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
330
|
+
* @param {string} valor Valor a preencher.
|
|
331
|
+
* @param {string} [descricao] Descrição da ação.
|
|
332
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
333
|
+
* @param {any} [pageParam] Page do Playwright (opcional, para auto-inicialização)
|
|
334
|
+
*/
|
|
335
|
+
static setText(elemento: string | ILocator, valor: string, descricao?: string, tirarPrint?: boolean, pageParam?: any, force?: boolean): Promise<void>;
|
|
336
|
+
/**
|
|
337
|
+
* Preenche um campo de data usando digitação caractere por caractere.
|
|
338
|
+
* ✅ Resolve problemas com campos de data que têm máscara ou validação especial.
|
|
339
|
+
* ✅ Usa keyboard.type() que simula digitação real, funcionando melhor com máscaras.
|
|
340
|
+
*
|
|
341
|
+
* @param {string|ILocator} elemento Seletor ou locator do campo de data.
|
|
342
|
+
* @param {string} data Data no formato esperado pelo campo (ex: "01/01/2025", "2025-01-01").
|
|
343
|
+
* @param {string} [descricao] Descrição da ação.
|
|
344
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
345
|
+
* @param {number} [delay=50] Delay entre cada caractere em ms (ajuste se a máscara for lenta).
|
|
346
|
+
* @param {DateFormat} [inputFormat] Formato de entrada da data (como você está passando).
|
|
347
|
+
* @param {DateFormat} [outputFormat] Formato de saída (como o campo espera receber).
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* // Campo com máscara DD/MM/YYYY (padrão brasileiro)
|
|
351
|
+
* await WebActions.setDate(campoDataNascimento, '15/03/1990', 'Preenchendo data de nascimento');
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* // Convertendo de formato brasileiro para americano
|
|
355
|
+
* await WebActions.setDate(campoData, '15/03/1990', 'Data', false, 50, 'DD/MM/YYYY', 'MM/DD/YYYY');
|
|
356
|
+
* // Resultado: digita 03/15/1990
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* // Convertendo de ISO para brasileiro
|
|
360
|
+
* await WebActions.setDate(campoData, '1990-03-15', 'Data', false, 50, 'YYYY-MM-DD', 'DD/MM/YYYY');
|
|
361
|
+
* // Resultado: digita 15/03/1990
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* // Usando DateOptions (forma mais limpa)
|
|
365
|
+
* await WebActions.setDate(campoData, '15/03/1990', {
|
|
366
|
+
* descricao: 'Data de nascimento',
|
|
367
|
+
* inputFormat: 'DD/MM/YYYY',
|
|
368
|
+
* outputFormat: 'YYYY-MM-DD'
|
|
369
|
+
* });
|
|
370
|
+
*/
|
|
371
|
+
static setDate(elemento: string | ILocator, data: string, descricaoOrOptions?: string | DateOptions, tirarPrint?: boolean, delay?: number, inputFormat?: DateFormat, outputFormat?: DateFormat): Promise<void>;
|
|
372
|
+
/**
|
|
373
|
+
* Preenche um campo de telefone (comportamento simples, como setDate).
|
|
374
|
+
* Tem comportamento semelhante a `setDate` (click, clear, type) e validação básica.
|
|
375
|
+
* Aceita `pressTab` para compatibilidade (padrão: true).
|
|
376
|
+
*
|
|
377
|
+
* @param elemento Seletor ou locator
|
|
378
|
+
* @param telefone Valor do telefone a ser inserido
|
|
379
|
+
* @param descricaoOrOptions Descrição ou opções (descricao, tirarPrint, delay, pressTab)
|
|
380
|
+
* @param tirarPrint Se deve tirar print
|
|
381
|
+
* @param delay Delay entre caracteres
|
|
382
|
+
* @param pressTab Se deve pressionar Tab ao final (padrão: true)
|
|
383
|
+
*/
|
|
384
|
+
static setPhone(elemento: string | ILocator, telefone: string, descricaoOrOptions?: string | {
|
|
385
|
+
descricao?: string;
|
|
386
|
+
tirarPrint?: boolean;
|
|
387
|
+
delay?: number;
|
|
388
|
+
pressTab?: boolean;
|
|
389
|
+
}, tirarPrint?: boolean, delay?: number, pressTab?: boolean): Promise<void>;
|
|
390
|
+
/**
|
|
391
|
+
* Preenche campo de data usando estratégia alternativa com clear + type.
|
|
392
|
+
* ✅ Útil quando setDate não funciona por causa de validações específicas.
|
|
393
|
+
* ✅ Tenta múltiplas estratégias até uma funcionar.
|
|
394
|
+
*
|
|
395
|
+
* @param {string|ILocator} elemento Seletor ou locator do campo de data.
|
|
396
|
+
* @param {string} data Data no formato esperado pelo campo (ex: "01/01/2025", "2025-01-01").
|
|
397
|
+
* @param {string} [descricao] Descrição da ação.
|
|
398
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
399
|
+
* @param {DateFormat} [inputFormat] Formato de entrada da data (como você está passando).
|
|
400
|
+
* @param {DateFormat} [outputFormat] Formato de saída (como o campo espera receber).
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* await WebActions.setDateRobust(campoDataNascimento, '15/03/1990', 'Preenchendo data de nascimento');
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* // Convertendo de formato brasileiro para americano
|
|
407
|
+
* await WebActions.setDateRobust(campoData, '15/03/1990', 'Data', false, 'DD/MM/YYYY', 'MM/DD/YYYY');
|
|
408
|
+
* // Resultado: digita 03/15/1990
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* // Convertendo de ISO para brasileiro
|
|
412
|
+
* await WebActions.setDateRobust(campoData, '1990-03-15', 'Data', false, 'YYYY-MM-DD', 'DD/MM/YYYY');
|
|
413
|
+
* // Resultado: digita 15/03/1990
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* // Usando DateOptions (forma mais limpa)
|
|
417
|
+
* await WebActions.setDateRobust(campoData, '15/03/1990', {
|
|
418
|
+
* descricao: 'Data de nascimento',
|
|
419
|
+
* inputFormat: 'DD/MM/YYYY',
|
|
420
|
+
* outputFormat: 'YYYY-MM-DD'
|
|
421
|
+
* });
|
|
422
|
+
*/
|
|
423
|
+
static setDateRobust(elemento: string | ILocator, data: string, descricaoOrOptions?: string | DateOptions, tirarPrint?: boolean, inputFormat?: DateFormat, outputFormat?: DateFormat, pressTab?: boolean): Promise<void>;
|
|
424
|
+
/**
|
|
425
|
+
* Seleciona uma opção a partir do XPath que aponta para a tag <option>.
|
|
426
|
+
* Ex: //select[@title='Visibilidade']/option[text()='Todas as cotações das organizações']
|
|
427
|
+
* Faz evaluate no browser para localizar o option, encontrar o select pai,
|
|
428
|
+
* aplicar o value/selected e disparar eventos 'input' e 'change'. Usa TestRecovery
|
|
429
|
+
* em caso de falha para tentar alternativas.
|
|
430
|
+
*/
|
|
431
|
+
/**
|
|
432
|
+
* @deprecated Use `selectOption(optionXPath, valor, descricao)` — todas as estratégias foram unificadas em selectOption.
|
|
433
|
+
*/
|
|
434
|
+
static selectOptionByXPath(optionXPath: string, descricao?: string): Promise<void>;
|
|
435
|
+
/**
|
|
436
|
+
* Preenche um campo de telefone de forma robusta (várias estratégias).
|
|
437
|
+
* Não pressiona `Tab` ao final para evitar mudanças indesejadas de foco.
|
|
438
|
+
*
|
|
439
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
440
|
+
* @param {string} telefone Valor do telefone a ser inserido.
|
|
441
|
+
* @param {string|{descricao?:string,tirarPrint?:boolean,delay?:number}} descricaoOrOptions Descrição ou opções.
|
|
442
|
+
* @param {boolean} [tirarPrint=false] Se deve capturar evidência.
|
|
443
|
+
* @param {number} [delay] Delay entre caracteres em ms.
|
|
444
|
+
*/
|
|
445
|
+
static setPhoneRobust(elemento: string | ILocator, telefone: string, descricaoOrOptions?: string | {
|
|
446
|
+
descricao?: string;
|
|
447
|
+
tirarPrint?: boolean;
|
|
448
|
+
delay?: number;
|
|
449
|
+
pressTab?: boolean;
|
|
450
|
+
}, tirarPrint?: boolean, delay?: number, pressTab?: boolean): Promise<void>;
|
|
451
|
+
/**
|
|
452
|
+
* Limpa um campo e digita o texto caractere por caractere.
|
|
453
|
+
* ✅ Útil para campos com máscaras, validações ou que não aceitam fill().
|
|
454
|
+
*
|
|
455
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
456
|
+
* @param {string} texto Texto a digitar.
|
|
457
|
+
* @param {string} [descricao] Descrição da ação.
|
|
458
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
459
|
+
* @param {number} [delay=30] Delay entre caracteres em ms.
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* await WebActions.clearAndType(campoCPF, '123.456.789-00', 'Preenchendo CPF');
|
|
463
|
+
*/
|
|
464
|
+
static clearAndType(elemento: string | ILocator, texto: string, descricao?: string, tirarPrint?: boolean, delay?: number): Promise<void>;
|
|
465
|
+
/**
|
|
466
|
+
* Preenche campo de data HTML5 (type="date") usando o valor nativo.
|
|
467
|
+
* ✅ Para campos <input type="date"> que esperam formato YYYY-MM-DD.
|
|
468
|
+
*
|
|
469
|
+
* @param {string|ILocator} elemento Seletor ou locator do campo de data HTML5.
|
|
470
|
+
* @param {string} data Data no formato ISO (YYYY-MM-DD) ou DD/MM/YYYY (será convertido).
|
|
471
|
+
* @param {string} [descricao] Descrição da ação.
|
|
472
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* // Formato ISO direto
|
|
476
|
+
* await WebActions.setDateNative(campoData, '1990-03-15', 'Data de nascimento');
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* // Formato brasileiro (será convertido automaticamente)
|
|
480
|
+
* await WebActions.setDateNative(campoData, '15/03/1990', 'Data de nascimento');
|
|
481
|
+
*
|
|
482
|
+
* @example
|
|
483
|
+
* // Com formato de entrada explícito (americano)
|
|
484
|
+
* await WebActions.setDateNative(campoData, '03/15/1990', 'Data', false, 'MM/DD/YYYY');
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* // Usando DateOptions
|
|
488
|
+
* await WebActions.setDateNative(campoData, '15/03/1990', {
|
|
489
|
+
* descricao: 'Data de nascimento',
|
|
490
|
+
* inputFormat: 'DD/MM/YYYY'
|
|
491
|
+
* });
|
|
492
|
+
*/
|
|
493
|
+
static setDateNative(elemento: string | ILocator, data: string, descricaoOrOptions?: string | DateOptions, tirarPrint?: boolean, inputFormat?: DateFormat): Promise<void>;
|
|
494
|
+
/**
|
|
495
|
+
* Converte uma data de um formato para outro.
|
|
496
|
+
*
|
|
497
|
+
* @param {string} data Data a ser convertida.
|
|
498
|
+
* @param {DateFormat} inputFormat Formato de entrada.
|
|
499
|
+
* @param {DateFormat} outputFormat Formato de saída.
|
|
500
|
+
* @returns {string} Data convertida.
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* // Brasileiro para Americano
|
|
504
|
+
* const dataUS = WebActions.convertDate('15/03/1990', 'DD/MM/YYYY', 'MM/DD/YYYY')
|
|
505
|
+
* // Resultado: '03/15/1990'
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* // Brasileiro para ISO
|
|
509
|
+
* const dataISO = WebActions.convertDate('15/03/1990', 'DD/MM/YYYY', 'YYYY-MM-DD')
|
|
510
|
+
* // Resultado: '1990-03-15'
|
|
511
|
+
* @deprecated Use `DateHelper.convert()` diretamente.
|
|
512
|
+
*/
|
|
513
|
+
static convertDate(data: string, inputFormat: DateFormat, outputFormat: DateFormat): string;
|
|
514
|
+
/**
|
|
515
|
+
* Converte uma data para formato ISO (YYYY-MM-DD).
|
|
516
|
+
*
|
|
517
|
+
* @param {string} data Data a ser convertida.
|
|
518
|
+
* @param {DateFormat} [inputFormat] Formato de entrada (detecta automaticamente se não informado).
|
|
519
|
+
* @returns {string} Data em formato ISO.
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* const dataISO = WebActions.toISODate('15/03/1990', 'DD/MM/YYYY')
|
|
523
|
+
* // Resultado: '1990-03-15'
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* // Detecta automaticamente o formato
|
|
527
|
+
* const dataISO = WebActions.toISODate('15/03/1990')
|
|
528
|
+
* // Resultado: '1990-03-15'
|
|
529
|
+
* @deprecated Use `DateHelper.toISO()` diretamente.
|
|
530
|
+
*/
|
|
531
|
+
static toISODate(data: string, inputFormat?: DateFormat): string;
|
|
532
|
+
/**
|
|
533
|
+
* Detecta automaticamente o formato de uma data.
|
|
534
|
+
*
|
|
535
|
+
* @param {string} data Data a ser analisada.
|
|
536
|
+
* @returns {DateFormat} Formato detectado.
|
|
537
|
+
*
|
|
538
|
+
* @example
|
|
539
|
+
* const formato = WebActions.detectDateFormat('15/03/1990')
|
|
540
|
+
* // Resultado: 'DD/MM/YYYY'
|
|
541
|
+
*
|
|
542
|
+
* @example
|
|
543
|
+
* const formato = WebActions.detectDateFormat('1990-03-15')
|
|
544
|
+
* // Resultado: 'YYYY-MM-DD'
|
|
545
|
+
* @deprecated Use `DateHelper.detectFormat()` diretamente.
|
|
546
|
+
*/
|
|
547
|
+
static detectDateFormat(data: string): DateFormat;
|
|
548
|
+
/**
|
|
549
|
+
* Troca apenas o separador da data mantendo a ordem dos campos.
|
|
550
|
+
* Útil quando o usuário passa dd-mm-yyyy mas o campo espera dd/mm/yyyy.
|
|
551
|
+
*
|
|
552
|
+
* @param {string} data Data com separador atual.
|
|
553
|
+
* @param {string} newSeparator Novo separador desejado ('/', '-', '.').
|
|
554
|
+
* @returns {string} Data com novo separador.
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* const dataBarra = WebActions.replaceDateSeparator('15-03-1990', '/')
|
|
558
|
+
* // Resultado: '15/03/1990'
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* const dataHifen = WebActions.replaceDateSeparator('15/03/1990', '-')
|
|
562
|
+
* // Resultado: '15-03-1990'
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* const dataPonto = WebActions.replaceDateSeparator('15/03/1990', '.')
|
|
566
|
+
* // Resultado: '15.03.1990'
|
|
567
|
+
* @deprecated Use `DateHelper.changeSeparator()` diretamente.
|
|
568
|
+
*/
|
|
569
|
+
static replaceDateSeparator(data: string, newSeparator: "/" | "-" | "."): string;
|
|
570
|
+
/**
|
|
571
|
+
* Realiza clique em elemento.
|
|
572
|
+
* ✅ MELHORADO: Espera elemento estar visível e estável antes de clicar.
|
|
573
|
+
*
|
|
574
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
575
|
+
* @param {string} [descricao] Descrição da ação.
|
|
576
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
577
|
+
* @param {any} [pageParam] Page do Playwright (opcional, para auto-inicialização)
|
|
578
|
+
*/
|
|
579
|
+
static click(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean, pageParam?: any): Promise<void>;
|
|
580
|
+
/**
|
|
581
|
+
* Realiza duplo clique em elemento.
|
|
582
|
+
* Possui as mesmas estratégias do click(): direta com eventos nativos, force,
|
|
583
|
+
* tabela, lista/overlay, iframe — cada uma com fallback via Test Recovery.
|
|
584
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
585
|
+
* @param {string} [descricao] Descrição da ação.
|
|
586
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
587
|
+
* @param {any} [pageParam] Page alternativa (auto-inicializa se fornecida).
|
|
588
|
+
*/
|
|
589
|
+
static doubleClick(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean, pageParam?: any): Promise<void>;
|
|
590
|
+
/**
|
|
591
|
+
* Realiza clique com botão direito.
|
|
592
|
+
* ✅ MELHORADO: Espera elemento estar visível antes de clicar.
|
|
593
|
+
*
|
|
594
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
595
|
+
* @param {string} [descricao] Descrição da ação.
|
|
596
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
597
|
+
*/
|
|
598
|
+
static rightClick(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
599
|
+
/**
|
|
600
|
+
* Move o mouse para o centro do elemento.
|
|
601
|
+
* ✅ MELHORADO: Espera elemento estar visível antes de mover.
|
|
602
|
+
*
|
|
603
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
604
|
+
* @param {string} [descricao] Descrição da ação.
|
|
605
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
606
|
+
*/
|
|
607
|
+
static mouseMove(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
608
|
+
/**
|
|
609
|
+
* Realiza hover sobre elemento.
|
|
610
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
611
|
+
* @param {string} [descricao] Descrição da ação.
|
|
612
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
613
|
+
*/
|
|
614
|
+
static hover(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
615
|
+
/**
|
|
616
|
+
* Seleciona opção em dropdown (por valor).
|
|
617
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
618
|
+
* @param {string} valor Valor da opção.
|
|
619
|
+
* @param {string} [descricao] Descrição da ação.
|
|
620
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
621
|
+
*/
|
|
622
|
+
static selectOption(elemento: string | ILocator, valor: string, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
623
|
+
/**
|
|
624
|
+
* Seleciona opção em lista (por label).
|
|
625
|
+
* ✅ MELHORADO: Espera elemento estar visível antes de selecionar.
|
|
626
|
+
*
|
|
627
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
628
|
+
* @param {string} texto Label da opção.
|
|
629
|
+
* @param {string} [descricao] Descrição da ação.
|
|
630
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
631
|
+
*/
|
|
632
|
+
/**
|
|
633
|
+
* @deprecated Use `selectOption(elemento, texto, descricao, tirarPrint)` — todas as estratégias foram unificadas em selectOption.
|
|
634
|
+
*/
|
|
635
|
+
static selectFromList(elemento: string | ILocator, texto: string, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
636
|
+
/**
|
|
637
|
+
* Seleciona opção em tabela (por texto).
|
|
638
|
+
* @param {string} seletorTabela Seletor da tabela.
|
|
639
|
+
* @param {string} texto Texto da célula.
|
|
640
|
+
* @param {string} [descricao] Descrição da ação.
|
|
641
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
642
|
+
*/
|
|
643
|
+
static selectTableOption(seletorTabela: string, texto: string, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
644
|
+
/**
|
|
645
|
+
* Switch to frame by selector.
|
|
646
|
+
* @param {string} seletorFrame Frame selector.
|
|
647
|
+
* @param {string} [descricao] Action description.
|
|
648
|
+
* @throws {Error} If frame is not found.
|
|
649
|
+
*/
|
|
650
|
+
/**
|
|
651
|
+
* 🔄 Recarrega a página atual e opcionalmente valida a presença de um elemento.
|
|
652
|
+
*
|
|
653
|
+
* @param {string | ILocator} [elementoValidacao] Elemento para validar após recarregar (opcional).
|
|
654
|
+
* @param {string} [descricao] Descrição da ação.
|
|
655
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
656
|
+
* @param {number} [timeout=30000] Timeout em ms para reload.
|
|
657
|
+
* @param {number} [waitAfterMs=0] Tempo extra de espera (ms) após o reload completar, antes de validar elemento. Útil para SPAs/Salesforce onde conteúdo assíncrono demora a renderizar.
|
|
658
|
+
* @returns {Promise<typeof WebActions>} Retorna a classe para encadeamento.
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* // Recarregar página simples
|
|
662
|
+
* await WebActions.refresh('Recarregar página inicial');
|
|
663
|
+
*
|
|
664
|
+
* @example
|
|
665
|
+
* // Recarregar e validar elemento
|
|
666
|
+
* await WebActions.refresh('#elemento-inicial', 'Recarregar e validar elemento inicial', true);
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* // Recarregar e esperar 3 segundos antes de prosseguir
|
|
670
|
+
* await WebActions.refresh('#painel', 'Aguardar painel carregar', false, 30000, 3000);
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* // Encadeamento
|
|
674
|
+
* await WebActions
|
|
675
|
+
* .refresh('#logo', 'Recarregar página')
|
|
676
|
+
* .click('#botao', 'Clicar no botão');
|
|
677
|
+
*/
|
|
678
|
+
static refresh(elementoValidacaoOrDescricao?: string | ILocator, descricao?: string, tirarPrint?: boolean, timeout?: number, waitAfterMs?: number): Promise<typeof WebActions>;
|
|
679
|
+
/**
|
|
680
|
+
* 🔄 Recarrega a página forçando bypass do cache (equivalente a Ctrl+Shift+R).
|
|
681
|
+
*
|
|
682
|
+
* Diferente do `refresh()` normal, este método limpa o cache do navegador
|
|
683
|
+
* antes de recarregar, garantindo que todos os recursos (JS, CSS, HTML)
|
|
684
|
+
* sejam buscados novamente do servidor — ideal para cenários onde o
|
|
685
|
+
* elemento não aparece porque o browser está usando uma versão cacheada.
|
|
686
|
+
*
|
|
687
|
+
* @param {string | ILocator} [elementoValidacao] Elemento para validar após recarregar.
|
|
688
|
+
* @param {string} [descricao] Descrição da ação.
|
|
689
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
690
|
+
* @param {number} [timeout=30000] Timeout em ms.
|
|
691
|
+
* @param {number} [waitAfterMs=0] Tempo extra de espera (ms) após o reload completar. Útil quando o conteúdo demora a renderizar após recarga completa.
|
|
692
|
+
* @returns {Promise<typeof WebActions>} Retorna a classe para encadeamento.
|
|
693
|
+
*
|
|
694
|
+
* @example
|
|
695
|
+
* // Hard refresh simples (Ctrl+Shift+R)
|
|
696
|
+
* await WebActions.hardRefresh('Forçar recarga completa');
|
|
697
|
+
*
|
|
698
|
+
* @example
|
|
699
|
+
* // Hard refresh e validar elemento que não aparecia
|
|
700
|
+
* await WebActions.hardRefresh('#painel-ofertas', 'Forçar recarga para exibir ofertas', true);
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* // Hard refresh com 5 segundos de espera extra
|
|
704
|
+
* await WebActions.hardRefresh('#grid-dados', 'Recarregar grid', false, 30000, 5000);
|
|
705
|
+
*/
|
|
706
|
+
static hardRefresh(elementoValidacaoOrDescricao?: string | ILocator, descricao?: string, tirarPrint?: boolean, timeout?: number, waitAfterMs?: number): Promise<typeof WebActions>;
|
|
707
|
+
/**
|
|
708
|
+
* Closes the current page.
|
|
709
|
+
* @param {string} [descricao] Action description.
|
|
710
|
+
*/
|
|
711
|
+
static closePage(descricao?: string): Promise<void>;
|
|
712
|
+
/**
|
|
713
|
+
* 🚨 Waits for a browser alert/dialog to appear.
|
|
714
|
+
* @param {number} [timeout=5000] Timeout in milliseconds to wait for alert.
|
|
715
|
+
* @param {string} [descricao] Action description.
|
|
716
|
+
* @param {boolean} [tirarPrint] Whether to capture evidence.
|
|
717
|
+
* @returns {Promise<string>} The alert message.
|
|
718
|
+
* @throws {Error} If alert doesn't appear within timeout.
|
|
719
|
+
*/
|
|
720
|
+
static waitForAlert(timeout?: number, descricao?: string, tirarPrint?: boolean): Promise<string>;
|
|
721
|
+
/**
|
|
722
|
+
* 🚨 NOVO: Clica em um alert/dialog do browser (aceitar ou cancelar).
|
|
723
|
+
* @param {boolean} [aceitar=true] If true accepts alert, if false dismisses.
|
|
724
|
+
* @param {string} [textoParaDigitar] Text to type in prompt alerts.
|
|
725
|
+
* @param {string} [descricao] Action description.
|
|
726
|
+
* @param {boolean} [tirarPrint] Whether to capture evidence.
|
|
727
|
+
* @returns {Promise<string>} The alert message that was clicked.
|
|
728
|
+
* @throws {Error} If no active alert exists.
|
|
729
|
+
*/
|
|
730
|
+
static clickAlert(aceitar?: boolean, textoParaDigitar?: string, descricao?: string, tirarPrint?: boolean): Promise<string>;
|
|
731
|
+
/**
|
|
732
|
+
* 🚨 Waits and automatically clicks an alert in a single action.
|
|
733
|
+
* @param {boolean} [aceitar=true] If true accepts alert, if false dismisses.
|
|
734
|
+
* @param {string} [textoParaDigitar] Text to type in prompt alerts.
|
|
735
|
+
* @param {number} [timeout=5000] Timeout in milliseconds to wait for alert.
|
|
736
|
+
* @param {string} [descricao] Action description.
|
|
737
|
+
* @param {boolean} [tirarPrint] Whether to capture evidence.
|
|
738
|
+
* @returns {Promise<string>} The alert message.
|
|
739
|
+
*/
|
|
740
|
+
static waitAndClickAlert(aceitar?: boolean, textoParaDigitar?: string, timeout?: number, descricao?: string, tirarPrint?: boolean): Promise<string>;
|
|
741
|
+
/**
|
|
742
|
+
* Realiza upload de arquivos em campo file.
|
|
743
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
744
|
+
* @param {string[]} filePaths Caminhos dos arquivos.
|
|
745
|
+
* @param {string} [descricao] Descrição da ação.
|
|
746
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
747
|
+
*/
|
|
748
|
+
static setFiles(elemento: string | ILocator, filePaths: string[], descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
749
|
+
/**
|
|
750
|
+
* Realiza scroll para coordenadas x, y com verificação de que o scroll aconteceu.
|
|
751
|
+
* Usa múltiplas estratégias: window.scrollTo, scrollBy, e element.scrollTop.
|
|
752
|
+
*
|
|
753
|
+
* @param {number} x Coordenada X.
|
|
754
|
+
* @param {number} y Coordenada Y.
|
|
755
|
+
* @param {string} [descricao] Descrição da ação.
|
|
756
|
+
*/
|
|
757
|
+
static scrollTo(x: number, y: number, descricao?: string): Promise<void>;
|
|
758
|
+
/**
|
|
759
|
+
* Realiza scroll até o elemento com verificação robusta.
|
|
760
|
+
* Usa múltiplas estratégias: scrollIntoViewIfNeeded, scrollIntoView via JS,
|
|
761
|
+
* e fallback com mouse.wheel. Verifica se o elemento ficou visível no viewport.
|
|
762
|
+
*
|
|
763
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
764
|
+
* @param {string} [descricao] Descrição da ação.
|
|
765
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
766
|
+
*/
|
|
767
|
+
static scrollToElement(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
768
|
+
/**
|
|
769
|
+
* Verifica se um elemento está visível dentro do viewport atual.
|
|
770
|
+
* @param el Locator do elemento
|
|
771
|
+
* @param page Página atual
|
|
772
|
+
* @returns true se o elemento está no viewport
|
|
773
|
+
*/
|
|
774
|
+
private static isElementInViewport;
|
|
775
|
+
/**
|
|
776
|
+
* 🖱️ Clica e segura por um tempo determinado no elemento informado.
|
|
777
|
+
* Compatível com Qandalf Java: clickAndHold(WebElement element, String descriptionToAction, int timeHold, Boolean getSnapshot)
|
|
778
|
+
*
|
|
779
|
+
* @param {string|ILocator} elemento Seletor ou locator do elemento.
|
|
780
|
+
* @param {string} descricao Descrição da ação para relatório.
|
|
781
|
+
* @param {number} timeHold Tempo que deseja segurar no elemento (em segundos).
|
|
782
|
+
* @param {boolean} [tirarPrint=false] Se deve tirar captura de tela.
|
|
783
|
+
* @returns {Promise<typeof WebActions>} Retorna a própria instância da classe para encadeamento.
|
|
784
|
+
*
|
|
785
|
+
* @example
|
|
786
|
+
* // Clicar e segurar por 2 segundos
|
|
787
|
+
* await WebActions.clickAndHold(
|
|
788
|
+
* '#botaoMostrarMensagem',
|
|
789
|
+
* 'Clicar no botão para mostrar mensagem',
|
|
790
|
+
* 2,
|
|
791
|
+
* true
|
|
792
|
+
* );
|
|
793
|
+
*
|
|
794
|
+
* @example
|
|
795
|
+
* // Encadeamento
|
|
796
|
+
* await WebActions
|
|
797
|
+
* .clickAndHold('#elemento', 'Segurar elemento', 3, true)
|
|
798
|
+
* .verificarExistencia('#mensagem', 'Validar mensagem');
|
|
799
|
+
*/
|
|
800
|
+
static clickAndHold(elemento: string | ILocator, descricao: string, timeHold: number, tirarPrint?: boolean): Promise<typeof WebActions>;
|
|
801
|
+
/**
|
|
802
|
+
* Verifies custom condition.
|
|
803
|
+
* @param {() => boolean|Promise<boolean>} condicao Condition function.
|
|
804
|
+
* @param {string} descricaoCondicao Condition description.
|
|
805
|
+
* @param {string} [descricao] Action description.
|
|
806
|
+
* @param {boolean} [tirarPrint] Whether to capture evidence.
|
|
807
|
+
* @returns {Promise<boolean>}
|
|
808
|
+
*/
|
|
809
|
+
static verifyCondition(condicao: () => boolean | Promise<boolean>, descricaoCondicao: string, descricao?: string, tirarPrint?: boolean): Promise<boolean>;
|
|
810
|
+
/**
|
|
811
|
+
* Presses a keyboard key.
|
|
812
|
+
* @param {string} tecla Key to press.
|
|
813
|
+
* @param {string} [descricao] Action description.
|
|
814
|
+
* @param {boolean} [tirarPrint] Whether to capture evidence.
|
|
815
|
+
*/
|
|
816
|
+
static pressKey(tecla: string, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
817
|
+
/**
|
|
818
|
+
* 🔧 Presses a key multiple times while holding a modifier key.
|
|
819
|
+
* Compatible with Qandalf Java: Actions.keyDown(Keys.CONTROL) + pressKey + Actions.keyUp(Keys.CONTROL)
|
|
820
|
+
*
|
|
821
|
+
* @param {'Control' | 'Shift' | 'Alt' | 'Meta'} modificador Modifier key to hold.
|
|
822
|
+
* @param {string} tecla Key to press (e.g., 'Subtract', 'Add', 'a', 'c').
|
|
823
|
+
* @param {number} [vezes=1] Number of times to press the key.
|
|
824
|
+
* @param {string} [descricao] Action description for report.
|
|
825
|
+
* @param {boolean} [tirarPrint=false] Whether to capture screenshot.
|
|
826
|
+
* @returns {Promise<typeof WebActions>} Returns WebActions for chaining.
|
|
827
|
+
*
|
|
828
|
+
* @example
|
|
829
|
+
* // Ctrl+- three times to zoom out
|
|
830
|
+
* await WebActions.pressWithModifier('Control', 'Subtract', 3, 'Zooming Out');
|
|
831
|
+
*
|
|
832
|
+
* @example
|
|
833
|
+
* // Ctrl+Shift+S for save as
|
|
834
|
+
* await WebActions.pressWithModifier('Control', 'Shift+s', 1, 'Save As');
|
|
835
|
+
*
|
|
836
|
+
* @example
|
|
837
|
+
* // Ctrl+C for copy
|
|
838
|
+
* await WebActions.pressWithModifier('Control', 'c', 1, 'Copy');
|
|
839
|
+
*/
|
|
840
|
+
static pressWithModifier(modificador: "Control" | "Shift" | "Alt" | "Meta", tecla: string, vezes?: number, descricao?: string, tirarPrint?: boolean): Promise<typeof WebActions>;
|
|
841
|
+
/**
|
|
842
|
+
* Waits for a fixed time in seconds.
|
|
843
|
+
* @param {number} seconds Time in seconds.
|
|
844
|
+
* @param {string} [description] Action description.
|
|
845
|
+
* @param {boolean} [takeScreenshotAfter=true] Whether to capture screenshot after wait.
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* // With screenshot (default) - 5 seconds
|
|
849
|
+
* await WebActions.fixedWait(5, 'Waiting for load')
|
|
850
|
+
*
|
|
851
|
+
* // Without screenshot - 3 seconds
|
|
852
|
+
* await WebActions.fixedWait(3, 'Waiting for load', false)
|
|
853
|
+
*/
|
|
854
|
+
static fixedWait(segundos: number, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
855
|
+
/**
|
|
856
|
+
* Espera até elemento estar visível.
|
|
857
|
+
* ✅ MELHORADO: Primeiro espera a página carregar (networkidle), depois procura o elemento.
|
|
858
|
+
*
|
|
859
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
860
|
+
* @param {number|WaitVisibilityOptions} [timeout] Timeout em ms ou objeto de opções.
|
|
861
|
+
* @param {string} [descricao] Descrição opcional quando usando assinatura posicional.
|
|
862
|
+
* @param {boolean} [tirarPrint] Evidência opcional quando usando assinatura posicional.
|
|
863
|
+
*
|
|
864
|
+
* @example
|
|
865
|
+
* await WebActions.waitForVisible('#botao')
|
|
866
|
+
* await WebActions.waitForVisible('#botao', 3000, 'Esperar botão', true)
|
|
867
|
+
* await WebActions.waitForVisible('#botao', 'Esperar botão sem timeout custom')
|
|
868
|
+
* await WebActions.waitForVisible('#botao', { descricao: 'Esperar', tirarPrint: true })
|
|
869
|
+
*/
|
|
870
|
+
static waitForVisible(elemento: string | ILocator, options?: WaitVisibilityOptions): Promise<void>;
|
|
871
|
+
static waitForVisible(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
872
|
+
static waitForVisible(elemento: string | ILocator, timeout?: number, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
873
|
+
/**
|
|
874
|
+
* Non-throwing variant of `waitForVisible` that returns boolean.
|
|
875
|
+
* Useful when you want to check visibility in conditions without throwing.
|
|
876
|
+
*
|
|
877
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
878
|
+
* @param {number|string|boolean|WaitVisibilityOptions} [timeoutOrOptions] Timeout em ms, descrição, ou objeto de opções.
|
|
879
|
+
* @param {string|boolean} [descricaoOrTirarPrint] Descrição ou flag de screenshot.
|
|
880
|
+
* @param {boolean} [tirarPrintFallback] Flag de screenshot quando usando assinatura posicional.
|
|
881
|
+
* @returns {Promise<boolean>} true se elemento está visível, false caso contrário.
|
|
882
|
+
*
|
|
883
|
+
* @example
|
|
884
|
+
* // Usar em condições sem lançar erro
|
|
885
|
+
* if (await WebActions.waitForVisibleBoolean('#modal', 3000)) {
|
|
886
|
+
* await WebActions.click('#closeModal');
|
|
887
|
+
* }
|
|
888
|
+
*
|
|
889
|
+
* @example
|
|
890
|
+
* // Verificar se elemento apareceu
|
|
891
|
+
* const isVisible = await WebActions.waitForVisibleBoolean('#successMessage', 5000, 'Aguardando mensagem');
|
|
892
|
+
* console.log(isVisible ? 'Mensagem apareceu!' : 'Mensagem não apareceu');
|
|
893
|
+
*/
|
|
894
|
+
static waitForVisibleBoolean(elemento: string | ILocator, timeoutOrOptions?: number | string | boolean | WaitVisibilityOptions, descricaoOrTirarPrint?: string | boolean, tirarPrintFallback?: boolean): Promise<boolean>;
|
|
895
|
+
static _waitForVisibleImpl(elemento: string | ILocator, opts: Required<WaitVisibilityOptions & Partial<ExtendedWaitVisibilityOptions>>): Promise<boolean>;
|
|
896
|
+
/**
|
|
897
|
+
* Ensure element is visible using a short initial probe, then consult TestRecovery if needed.
|
|
898
|
+
* - initial probe: 5s (or less if maxTimeout smaller)
|
|
899
|
+
* - max default timeout: 30s
|
|
900
|
+
*/
|
|
901
|
+
static ensureVisibleWithRecovery(elOrSelector: string | ILocator, explicitTimeoutMs?: number): Promise<void>;
|
|
902
|
+
/**
|
|
903
|
+
try { await page.waitForLoadState('domcontentloaded', { timeout: 1500 }); } catch {}
|
|
904
|
+
// preparar candidatos de selector (normalize-space / parent select etc.)
|
|
905
|
+
const originalSelector = WebActions.extractSelector(elemento)
|
|
906
|
+
const selectorCandidates = WebActions.getSelectorCandidates(originalSelector)
|
|
907
|
+
const matchedSelector = await WebActions.findFirstMatchingSelector(page, selectorCandidates)
|
|
908
|
+
const selectorToUse = matchedSelector || originalSelector
|
|
909
|
+
* Useful for loaders, spinners, or loading elements.
|
|
910
|
+
const selector = selectorToUse;
|
|
911
|
+
const sel = selector
|
|
912
|
+
const selector = selectorToUse;
|
|
913
|
+
const selector = selectorToUse;
|
|
914
|
+
const selector = selectorToUse;
|
|
915
|
+
try {
|
|
916
|
+
const selector = selectorToUse;
|
|
917
|
+
* @example
|
|
918
|
+
* // Wait for loader to disappear
|
|
919
|
+
* await WebActions.waitWhileVisible('#loader', 500, 30000, 'Waiting for loader');
|
|
920
|
+
*
|
|
921
|
+
* // Wait for spinner with default timeout
|
|
922
|
+
* await WebActions.waitWhileVisible('.spinner', 1000, undefined, 'Waiting for spinner');
|
|
923
|
+
*/
|
|
924
|
+
static waitWhileVisible(elemento: string | ILocator, intervalo?: number, timeout?: number, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
925
|
+
/**
|
|
926
|
+
* Waits until element is clickable.
|
|
927
|
+
* @param {string|ILocator} elemento Selector or locator.
|
|
928
|
+
* @param {number} [timeout] Timeout in ms.
|
|
929
|
+
* @param {string} [descricao] Action description.
|
|
930
|
+
* @param {boolean} [tirarPrint] Whether to capture evidence.
|
|
931
|
+
*/
|
|
932
|
+
static waitForClickable(elemento: string | ILocator, timeout?: number, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
933
|
+
/**
|
|
934
|
+
* Validates if an element is present and visible on the screen.
|
|
935
|
+
* Useful for validating elements after login or navigation.
|
|
936
|
+
*
|
|
937
|
+
* @param {string|ILocator} elemento Element selector or locator to validate.
|
|
938
|
+
* @param {string} [descricao] Description of the action (used in reports).
|
|
939
|
+
* @param {boolean} [tirarPrint=false] Whether to capture a screenshot.
|
|
940
|
+
* @param {number} [timeout] Timeout in ms (default: project timeout).
|
|
941
|
+
* @returns {Promise<boolean>} Returns true if element is visible, false otherwise.
|
|
942
|
+
*
|
|
943
|
+
* @example
|
|
944
|
+
* // Validate element presence after login
|
|
945
|
+
* await WebActions.validateObject('#dashboard', 'Validar presença do dashboard', true);
|
|
946
|
+
*
|
|
947
|
+
* // Validate without screenshot
|
|
948
|
+
* const isVisible = await WebActions.validateObject('.welcome-message', 'Verificar mensagem de boas-vindas');
|
|
949
|
+
*
|
|
950
|
+
* // With custom timeout
|
|
951
|
+
* await WebActions.validateObject('#userMenu', 'Validar menu do usuário', true, 10000);
|
|
952
|
+
*/
|
|
953
|
+
static validateObject(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean, timeout?: number): Promise<boolean>;
|
|
954
|
+
/**
|
|
955
|
+
* Validates if elements exist and returns the count.
|
|
956
|
+
* Supports toHaveCount-style assertions.
|
|
957
|
+
* Does NOT throw an error, just returns the count for flexible assertions.
|
|
958
|
+
*
|
|
959
|
+
* @param {string|ILocator} elemento Element selector or locator to validate.
|
|
960
|
+
* @param {string} [descricao] Description of the action (used in reports).
|
|
961
|
+
* @param {boolean} [tirarPrint=false] Whether to capture a screenshot.
|
|
962
|
+
* @param {number} [expectedCount] Optional expected count - if provided, validates exact match.
|
|
963
|
+
* @returns {Promise<number>} Returns the count of matching elements.
|
|
964
|
+
*
|
|
965
|
+
* @example
|
|
966
|
+
* // Get count of elements
|
|
967
|
+
* const count = await WebActions.validateObjectCount('.list-item', 'Contar itens');
|
|
968
|
+
* expect(count).toBeGreaterThan(0);
|
|
969
|
+
*
|
|
970
|
+
* // Validate exact count (like toHaveCount)
|
|
971
|
+
* const count = await WebActions.validateObjectCount('.row', 'Validar linhas', false, 5);
|
|
972
|
+
* // Throws if count !== 5
|
|
973
|
+
*
|
|
974
|
+
* // Use in assertions
|
|
975
|
+
* const itemCount = await WebActions.validateObjectCount('#cart .item', 'Itens no carrinho');
|
|
976
|
+
* expect(itemCount).toBe(3);
|
|
977
|
+
*/
|
|
978
|
+
static validateObjectCount(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean, expectedCount?: number): Promise<number>;
|
|
979
|
+
/**
|
|
980
|
+
* Counts the number of elements matching the selector.
|
|
981
|
+
* Useful for validations that need to check element count.
|
|
982
|
+
*
|
|
983
|
+
* @param {string|ILocator} elemento Element selector or locator to count.
|
|
984
|
+
* @param {string} [descricao] Description of the action (used in reports).
|
|
985
|
+
* @param {boolean} [tirarPrint=false] Whether to capture a screenshot.
|
|
986
|
+
* @returns {Promise<number>} Returns the count of matching elements.
|
|
987
|
+
*
|
|
988
|
+
* @example
|
|
989
|
+
* // Count items in a list
|
|
990
|
+
* const count = await WebActions.countElements('.list-item', 'Contar itens da lista');
|
|
991
|
+
* console.log(`Encontrados ${count} itens`);
|
|
992
|
+
*
|
|
993
|
+
* // Validate no errors exist
|
|
994
|
+
* const errorCount = await WebActions.countElements('.error-message', 'Contar erros');
|
|
995
|
+
* if (errorCount === 0) {
|
|
996
|
+
* console.log('Nenhum erro encontrado!');
|
|
997
|
+
* }
|
|
998
|
+
*/
|
|
999
|
+
static countElements(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean): Promise<number>;
|
|
1000
|
+
/**
|
|
1001
|
+
* Validates if an element is NOT present or NOT visible on the screen.
|
|
1002
|
+
* Useful for validating that elements have been removed or are hidden.
|
|
1003
|
+
* Supports count validation using `.count(0)` style.
|
|
1004
|
+
*
|
|
1005
|
+
* @param {string|ILocator} elemento Element selector or locator to validate.
|
|
1006
|
+
* @param {string} [descricao] Description of the action (used in reports).
|
|
1007
|
+
* @param {boolean} [tirarPrint=false] Whether to capture a screenshot.
|
|
1008
|
+
* @param {number} [timeout] Timeout in ms (default: project timeout).
|
|
1009
|
+
* @returns {Promise<boolean>} Returns true if element is NOT visible, false otherwise.
|
|
1010
|
+
*
|
|
1011
|
+
* @example
|
|
1012
|
+
* // Validate that loading spinner disappeared
|
|
1013
|
+
* await WebActions.validateObjectNotExists('.loading-spinner', 'Validar que spinner desapareceu', true);
|
|
1014
|
+
*
|
|
1015
|
+
* // Validate error message is not shown
|
|
1016
|
+
* const isHidden = await WebActions.validateObjectNotExists('#errorMsg', 'Verificar ausência de erro');
|
|
1017
|
+
*
|
|
1018
|
+
* // With custom timeout
|
|
1019
|
+
* await WebActions.validateObjectNotExists('.modal', 'Validar que modal fechou', true, 5000);
|
|
1020
|
+
*
|
|
1021
|
+
* // Using locator directly (validates count === 0)
|
|
1022
|
+
* await WebActions.validateObjectNotExists(this.divError(), 'Validar sem erros');
|
|
1023
|
+
*/
|
|
1024
|
+
static validateObjectNotExists(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean, timeout?: number): Promise<boolean>;
|
|
1025
|
+
/**
|
|
1026
|
+
* Validates if elements matching the selector do NOT exist (count === 0).
|
|
1027
|
+
* Returns the count of elements found, useful for assertions.
|
|
1028
|
+
* Does NOT throw an error, just returns the count.
|
|
1029
|
+
*
|
|
1030
|
+
* @param {string|ILocator} elemento Element selector or locator to validate.
|
|
1031
|
+
* @param {string} [descricao] Description of the action (used in reports).
|
|
1032
|
+
* @param {boolean} [tirarPrint=false] Whether to capture a screenshot.
|
|
1033
|
+
* @returns {Promise<number>} Returns the count of matching elements (0 if none found).
|
|
1034
|
+
*
|
|
1035
|
+
* @example
|
|
1036
|
+
* // Validate no errors exist and get count
|
|
1037
|
+
* const errorCount = await WebActions.validateObjectNotExistsCount('.error-message', 'Verificar ausência de erros');
|
|
1038
|
+
* if (errorCount === 0) {
|
|
1039
|
+
* console.log('Nenhum erro encontrado!');
|
|
1040
|
+
* } else {
|
|
1041
|
+
* console.log(`Ainda existem ${errorCount} erro(s)`);
|
|
1042
|
+
* }
|
|
1043
|
+
*
|
|
1044
|
+
* // Use in assertions
|
|
1045
|
+
* const count = await WebActions.validateObjectNotExistsCount('#modal', 'Validar que modal fechou');
|
|
1046
|
+
* expect(count).toBe(0);
|
|
1047
|
+
*/
|
|
1048
|
+
static validateObjectNotExistsCount(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean): Promise<number>;
|
|
1049
|
+
/**
|
|
1050
|
+
* Validates that an element has the expected count.
|
|
1051
|
+
* Works like Playwright's expect(locator).toHaveCount(n).
|
|
1052
|
+
*
|
|
1053
|
+
* @param {string|ILocator} elemento Element selector or locator to validate.
|
|
1054
|
+
* @param {number} expectedCount Expected number of elements.
|
|
1055
|
+
* @param {string} [descricao] Description of the action (used in reports).
|
|
1056
|
+
* @param {boolean} [tirarPrint=false] Whether to capture a screenshot.
|
|
1057
|
+
* @param {number} [timeout] Timeout in ms (default: project timeout).
|
|
1058
|
+
* @returns {Promise<boolean>} Returns true if count matches, throws error otherwise.
|
|
1059
|
+
*
|
|
1060
|
+
* @example
|
|
1061
|
+
* // Validate no error messages exist (count === 0)
|
|
1062
|
+
* await WebActions.toHaveCount(this.divMessageError(), 0, 'Validando que não há erros');
|
|
1063
|
+
*
|
|
1064
|
+
* // Validate exactly 5 items in list
|
|
1065
|
+
* await WebActions.toHaveCount('.list-item', 5, 'Validando 5 itens na lista');
|
|
1066
|
+
*
|
|
1067
|
+
* // Validate at least one result (will fail if count !== 1)
|
|
1068
|
+
* await WebActions.toHaveCount('#result', 1, 'Validando resultado único');
|
|
1069
|
+
*/
|
|
1070
|
+
static toHaveCount(elemento: string | ILocator, expectedCount: number, descricao?: string, tirarPrint?: boolean, timeout?: number): Promise<boolean>;
|
|
1071
|
+
/**
|
|
1072
|
+
* Waits for network idle state.
|
|
1073
|
+
* @param {string} [descricao] Action description.
|
|
1074
|
+
* @param {number} [timeout] Timeout in ms.
|
|
1075
|
+
* @param {boolean} [tirarPrint] Whether to capture evidence.
|
|
1076
|
+
*/
|
|
1077
|
+
static waitForNetworkIdle(descricao?: string, timeout?: number, tirarPrint?: boolean): Promise<void>;
|
|
1078
|
+
/**
|
|
1079
|
+
* Waits for navigation (load, domcontentloaded, etc).
|
|
1080
|
+
* @param {string} [descricao] Action description.
|
|
1081
|
+
* @param {number} [timeout] Timeout in ms.
|
|
1082
|
+
* @param {string} [waitUntil] Navigation state.
|
|
1083
|
+
* @param {boolean} [tirarPrint] Whether to capture evidence.
|
|
1084
|
+
*/
|
|
1085
|
+
static waitForNavigation(descricao?: string, timeout?: number, waitUntil?: string, tirarPrint?: boolean): Promise<void>;
|
|
1086
|
+
/**
|
|
1087
|
+
* Captures screenshot and attaches to report.
|
|
1088
|
+
* @param {string} descricao Evidence description.
|
|
1089
|
+
* @returns {Promise<string>} Path of captured screenshot
|
|
1090
|
+
*/
|
|
1091
|
+
static takeScreenshot(descricao: string): Promise<string>;
|
|
1092
|
+
/**
|
|
1093
|
+
* Gets field/input value.
|
|
1094
|
+
* @param {string|ILocator} elemento Selector or locator.
|
|
1095
|
+
* @param {string} [descricao] Action description.
|
|
1096
|
+
* @param {boolean} [tirarPrint] Whether to capture evidence.
|
|
1097
|
+
* @returns {Promise<string|null>}
|
|
1098
|
+
*/
|
|
1099
|
+
static getFieldValue(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean): Promise<string | null>;
|
|
1100
|
+
/**
|
|
1101
|
+
* Gets element attribute.
|
|
1102
|
+
* @param {string|ILocator} elemento Selector or locator.
|
|
1103
|
+
* @param {string} atributo Attribute name.
|
|
1104
|
+
* @param {string} [descricao] Action description.
|
|
1105
|
+
* @param {boolean} [tirarPrint] Whether to capture evidence.
|
|
1106
|
+
* @returns {Promise<string|null>}
|
|
1107
|
+
*/
|
|
1108
|
+
static getAttribute(elemento: string | ILocator, atributo: string, descricao?: string, tirarPrint?: boolean): Promise<string | null>;
|
|
1109
|
+
/**
|
|
1110
|
+
* Verifica se o elemento existe no DOM (não necessariamente visível).
|
|
1111
|
+
* Retorna um objeto com `exists` e `message` para maior compatibilidade com validações.
|
|
1112
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
1113
|
+
* @param {string} [descricao] Descrição da ação.
|
|
1114
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
1115
|
+
* @returns {Promise<{exists: boolean, message: string}>}
|
|
1116
|
+
*/
|
|
1117
|
+
static verifyExists(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean): Promise<{
|
|
1118
|
+
exists: boolean;
|
|
1119
|
+
message: string;
|
|
1120
|
+
}>;
|
|
1121
|
+
/**
|
|
1122
|
+
* Clears field/input.
|
|
1123
|
+
* @param {string|ILocator} elemento Selector or locator.
|
|
1124
|
+
* @param {string} [descricao] Action description.
|
|
1125
|
+
* @param {boolean} [tirarPrint] Whether to capture evidence.
|
|
1126
|
+
*/
|
|
1127
|
+
static clearField(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
1128
|
+
/**
|
|
1129
|
+
* Validates if checkbox is checked.
|
|
1130
|
+
* @param {string|ILocator} elemento Selector or locator.
|
|
1131
|
+
* @param {string} [descricao] Action description.
|
|
1132
|
+
* @param {boolean} [tirarPrint] Whether to capture evidence.
|
|
1133
|
+
* @returns {Promise<{checked: boolean, message: string}>}
|
|
1134
|
+
*/
|
|
1135
|
+
static validateCheckboxChecked(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean): Promise<{
|
|
1136
|
+
checked: boolean;
|
|
1137
|
+
message: string;
|
|
1138
|
+
}>;
|
|
1139
|
+
/**
|
|
1140
|
+
* Waits for element to appear (alias for waitForVisible).
|
|
1141
|
+
* @deprecated Use `waitForVisible()` diretamente.
|
|
1142
|
+
*/
|
|
1143
|
+
static waitForElement(elemento: ILocator | string, descricao?: string, timeout?: number): Promise<void>;
|
|
1144
|
+
/**
|
|
1145
|
+
* Waits for element to be visible (alias for waitForVisible).
|
|
1146
|
+
* @deprecated Use `waitForVisible()` diretamente.
|
|
1147
|
+
*/
|
|
1148
|
+
static waitForElementVisible(elemento: ILocator | string, descricao?: string, timeout?: number): Promise<void>;
|
|
1149
|
+
/**
|
|
1150
|
+
* Waits for element to be removed/detached.
|
|
1151
|
+
*/
|
|
1152
|
+
static waitForElementDetached(elemento: ILocator | string, descricao?: string, timeout?: number): Promise<void>;
|
|
1153
|
+
/**
|
|
1154
|
+
* Checks if element is visible.
|
|
1155
|
+
*/
|
|
1156
|
+
static isVisible(elemento: ILocator | string, descricao?: string): Promise<boolean>;
|
|
1157
|
+
/**
|
|
1158
|
+
* Checks if element is enabled.
|
|
1159
|
+
*/
|
|
1160
|
+
static isEnabled(elemento: ILocator | string, descricao?: string): Promise<boolean>;
|
|
1161
|
+
/**
|
|
1162
|
+
* Gets element text (alias for getText).
|
|
1163
|
+
*/
|
|
1164
|
+
static getText(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean): Promise<string>;
|
|
1165
|
+
static getTextContent(elemento: ILocator | string, descricao?: string, tirarPrint?: boolean): Promise<string>;
|
|
1166
|
+
/**
|
|
1167
|
+
* Checks a checkbox.
|
|
1168
|
+
*/
|
|
1169
|
+
static checkCheckbox(elemento: ILocator | string, descricao?: string, tirarPrint?: boolean, minIntervalMs?: number): Promise<void>;
|
|
1170
|
+
/**
|
|
1171
|
+
* Unchecks a checkbox.
|
|
1172
|
+
*/
|
|
1173
|
+
static uncheckCheckbox(elemento: ILocator | string, descricao?: string, tirarPrint?: boolean, minIntervalMs?: number): Promise<void>;
|
|
1174
|
+
/**
|
|
1175
|
+
* Types text slowly into element.
|
|
1176
|
+
*/
|
|
1177
|
+
static typeSlowly(elemento: ILocator | string, texto: string, descricao?: string, delay?: number, tirarPrint?: boolean): Promise<void>;
|
|
1178
|
+
/**
|
|
1179
|
+
* Focuses on an element.
|
|
1180
|
+
*/
|
|
1181
|
+
static focus(elemento: ILocator | string, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Goes back one page in history.
|
|
1184
|
+
*/
|
|
1185
|
+
static goBack(descricao?: string, timeout?: number): Promise<void>;
|
|
1186
|
+
/**
|
|
1187
|
+
* Goes forward one page in history.
|
|
1188
|
+
*/
|
|
1189
|
+
static goForward(descricao?: string, timeout?: number): Promise<void>;
|
|
1190
|
+
/**
|
|
1191
|
+
* Sets the viewport size.
|
|
1192
|
+
*/
|
|
1193
|
+
static setViewportSize(width: number, height: number, descricao?: string): Promise<void>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Executes JavaScript code on the page.
|
|
1196
|
+
*/
|
|
1197
|
+
static executeJavaScript(codigo: string, descricao?: string): Promise<any>;
|
|
1198
|
+
/**
|
|
1199
|
+
* Waits for page load state.
|
|
1200
|
+
*/
|
|
1201
|
+
static waitForLoad(estado?: "load" | "domcontentloaded" | "networkidle", descricao?: string, timeout?: number): Promise<void>;
|
|
1202
|
+
/**
|
|
1203
|
+
* 🆕 Espera a página ficar completamente pronta para interação.
|
|
1204
|
+
* Ideal para aplicações SPA lentas como Salesforce/SFA.
|
|
1205
|
+
* Combina: networkidle + espera spinners sumirem + estabilização DOM.
|
|
1206
|
+
*
|
|
1207
|
+
* @param {string} [descricao] Descrição da ação.
|
|
1208
|
+
* @param {number} [timeout] Timeout em ms (default: 60000).
|
|
1209
|
+
* @param {string[]} [spinnerSelectors] Seletores de spinners/loaders a esperar sumirem.
|
|
1210
|
+
* @param {boolean} [tirarPrint] Se deve capturar screenshot após estabilização.
|
|
1211
|
+
*
|
|
1212
|
+
* @example
|
|
1213
|
+
* await WebActions.waitForPageReady('Aguardando dashboard carregar')
|
|
1214
|
+
* await WebActions.waitForPageReady('Após login', 120000, ['.spinner', '.loading'])
|
|
1215
|
+
*/
|
|
1216
|
+
static waitForPageReady(descricao?: string, timeout?: number, spinnerSelectors?: string[], tirarPrint?: boolean): Promise<void>;
|
|
1217
|
+
/**
|
|
1218
|
+
* 🆕 Clica e espera a página carregar completamente.
|
|
1219
|
+
* Ideal para cliques que causam navegação em SPAs lentas.
|
|
1220
|
+
*
|
|
1221
|
+
* @param {string|ILocator} elemento Seletor ou locator.
|
|
1222
|
+
* @param {string} [descricao] Descrição da ação.
|
|
1223
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
1224
|
+
* @param {number} [timeout] Timeout para aguardar carregamento.
|
|
1225
|
+
*
|
|
1226
|
+
* @example
|
|
1227
|
+
* await WebActions.clickAndWait('#btnLogin', 'Clicando em Login')
|
|
1228
|
+
* await WebActions.clickAndWait(page.getByRole('button', { name: 'Entrar' }), 'Login')
|
|
1229
|
+
*/
|
|
1230
|
+
static clickAndWait(elemento: string | ILocator, descricao?: string, tirarPrint?: boolean, timeout?: number): Promise<void>;
|
|
1231
|
+
/**
|
|
1232
|
+
* 🆕 Clica em um menu/dropdown e depois clica na opção desejada.
|
|
1233
|
+
* Ideal para menus dinâmicos que aparecem após clique (ex: dropdowns, context menus).
|
|
1234
|
+
*
|
|
1235
|
+
* @param {string|ILocator} menuElement Seletor ou locator do botão/trigger do menu.
|
|
1236
|
+
* @param {string|ILocator} optionElement Seletor ou locator da opção dentro do menu.
|
|
1237
|
+
* @param {string} [descricao] Descrição da ação.
|
|
1238
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
1239
|
+
* @param {number} [waitMs] Tempo em ms para aguardar opção aparecer (default: 3000).
|
|
1240
|
+
* @param {boolean} [forceClick] Se deve forçar o clique na opção (default: true).
|
|
1241
|
+
*
|
|
1242
|
+
* @example
|
|
1243
|
+
* // Menu dropdown simples
|
|
1244
|
+
* await WebActions.clickMenuOption('#btnMenu', '#opcaoAnexos', 'Selecionar Anexos')
|
|
1245
|
+
*
|
|
1246
|
+
* @example
|
|
1247
|
+
* // Menu com seta e opções dinâmicas
|
|
1248
|
+
* await WebActions.clickMenuOption(
|
|
1249
|
+
* this.botaoSetaListaTelas,
|
|
1250
|
+
* this.linkTelaLista('Anexos'),
|
|
1251
|
+
* 'Acessar menu Anexos',
|
|
1252
|
+
* true
|
|
1253
|
+
* )
|
|
1254
|
+
*/
|
|
1255
|
+
static clickMenuOption(menuElement: string | ILocator, optionElement: string | ILocator, descricao?: string, tirarPrint?: boolean, waitMs?: number, forceClick?: boolean): Promise<void>;
|
|
1256
|
+
/**
|
|
1257
|
+
* 🆕 Clica em um dropdown e seleciona uma opção por texto visível.
|
|
1258
|
+
* Ideal para selects customizados ou dropdowns que não são <select> nativo.
|
|
1259
|
+
*
|
|
1260
|
+
* @param {string|ILocator} dropdownElement Seletor ou locator do dropdown.
|
|
1261
|
+
* @param {string} optionText Texto da opção a selecionar.
|
|
1262
|
+
* @param {string} [optionSelector] Seletor base das opções (default: tenta detectar).
|
|
1263
|
+
* @param {string} [descricao] Descrição da ação.
|
|
1264
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
1265
|
+
*
|
|
1266
|
+
* @example
|
|
1267
|
+
* // Dropdown customizado
|
|
1268
|
+
* await WebActions.selectDropdownOption(
|
|
1269
|
+
* this.campoVisibilidade,
|
|
1270
|
+
* 'Todas as cotações das organizações',
|
|
1271
|
+
* undefined,
|
|
1272
|
+
* 'Selecionando visibilidade'
|
|
1273
|
+
* )
|
|
1274
|
+
*/
|
|
1275
|
+
static selectDropdownOption(dropdownElement: string | ILocator, optionText: string, optionSelector?: string, descricao?: string, tirarPrint?: boolean): Promise<void>;
|
|
1276
|
+
/**
|
|
1277
|
+
* Obtém a URL atual da página.
|
|
1278
|
+
* @param descricao - Descrição da ação
|
|
1279
|
+
* @param tirarPrint - Se deve tirar screenshot
|
|
1280
|
+
* @returns URL atual da página
|
|
1281
|
+
*/
|
|
1282
|
+
static getUrl(descricao?: string, tirarPrint?: boolean): Promise<string>;
|
|
1283
|
+
/**
|
|
1284
|
+
* Valida se dois valores são iguais.
|
|
1285
|
+
* @param {any} valorAtual Valor atual obtido.
|
|
1286
|
+
* @param {any} valorEsperado Valor esperado.
|
|
1287
|
+
* @param {string} [descricao] Descrição da validação.
|
|
1288
|
+
* @param {boolean} [tirarPrint] Se deve capturar evidência.
|
|
1289
|
+
* @returns {Promise<boolean>} True se os valores são iguais.
|
|
1290
|
+
* @throws {Error} Se os valores não são iguais.
|
|
1291
|
+
*/
|
|
1292
|
+
static validateEquals(valorAtual: any, valorEsperado: any, descricao?: string, tirarPrint?: boolean): Promise<boolean>;
|
|
1293
|
+
/**
|
|
1294
|
+
* 🖼️ Troca o foco para um iframe específico.
|
|
1295
|
+
* Permite interagir com elementos dentro de iframes.
|
|
1296
|
+
*
|
|
1297
|
+
* @param {string | ILocator} element Seletor ou Locator do iframe.
|
|
1298
|
+
* @param {string} descriptionToAction Descrição da ação para relatório.
|
|
1299
|
+
* @param {boolean} [getSnapShot=false] Se deve tirar captura de tela.
|
|
1300
|
+
* @returns {Promise<typeof WebActions>} Retorna a classe para encadeamento.
|
|
1301
|
+
* @throws {Error} Se o iframe não for encontrado.
|
|
1302
|
+
*
|
|
1303
|
+
* @example
|
|
1304
|
+
* // Uso com seletor string
|
|
1305
|
+
* await WebActions.switchTo('#meuIframe', 'Mudar para iframe do formulário', true);
|
|
1306
|
+
* await WebActions.setText('#campoNoIframe', 'valorTeste', 'Preencher campo', false);
|
|
1307
|
+
* await WebActions.switchToDefault('Voltar para página principal');
|
|
1308
|
+
*
|
|
1309
|
+
* @example
|
|
1310
|
+
* // Uso com Locator
|
|
1311
|
+
* const iframeLocator = page.locator('iframe[name="formFrame"]');
|
|
1312
|
+
* await WebActions.switchTo(iframeLocator, 'Acessar iframe de formulário', true);
|
|
1313
|
+
*/
|
|
1314
|
+
static switchTo(element: string | ILocator, descriptionToAction: string, getSnapShot?: boolean): Promise<typeof WebActions>;
|
|
1315
|
+
/**
|
|
1316
|
+
* 🏠 Volta o foco para a página principal (sai do iframe).
|
|
1317
|
+
*
|
|
1318
|
+
* @param {string} descriptionToAction Descrição da ação para relatório.
|
|
1319
|
+
* @param {boolean} [getSnapShot=false] Se deve tirar captura de tela.
|
|
1320
|
+
* @returns {Promise<typeof WebActions>} Retorna a classe para encadeamento.
|
|
1321
|
+
*
|
|
1322
|
+
* @example
|
|
1323
|
+
* await WebActions.switchTo('#meuIframe', 'Entrar no iframe', true);
|
|
1324
|
+
* await WebActions.setText('#campo', 'valor', 'Preencher', false);
|
|
1325
|
+
* await WebActions.switchToDefault('Voltar para página padrão');
|
|
1326
|
+
*/
|
|
1327
|
+
static switchToDefault(descriptionToAction: string, getSnapShot?: boolean): Promise<typeof WebActions>;
|
|
1328
|
+
/**
|
|
1329
|
+
* 🪟 Troca o foco para uma nova janela/aba baseado na URL.
|
|
1330
|
+
* Útil quando um clique abre uma nova janela e você precisa interagir com ela.
|
|
1331
|
+
*
|
|
1332
|
+
* @param {string} url URL (ou parte dela) da nova janela.
|
|
1333
|
+
* @param {string} descriptionToAction Descrição da ação para relatório.
|
|
1334
|
+
* @param {boolean} [getSnapShot=false] Se deve tirar captura de tela.
|
|
1335
|
+
* @returns {Promise<typeof WebActions>} Retorna a classe para encadeamento.
|
|
1336
|
+
* @throws {Error} Se a janela com a URL especificada não for encontrada.
|
|
1337
|
+
*
|
|
1338
|
+
* @example
|
|
1339
|
+
* // Clicar em link que abre nova janela e mudar para ela
|
|
1340
|
+
* await WebActions.click('#linkNovaJanela', 'Abrir nova janela', true);
|
|
1341
|
+
* await WebActions.switchToWindowByUrl('http://example.com/nova', 'Mudar para nova janela', true);
|
|
1342
|
+
* // Agora você está na nova janela
|
|
1343
|
+
* await WebActions.getText('#tituloNovo', 'Obter título', false);
|
|
1344
|
+
*/
|
|
1345
|
+
static switchToWindowByUrl(url: string, descriptionToAction: string, getSnapShot?: boolean): Promise<typeof WebActions>;
|
|
1346
|
+
/**
|
|
1347
|
+
* 🪟 Troca o foco para uma nova janela/aba baseado no título.
|
|
1348
|
+
*
|
|
1349
|
+
* @param {string} title Título (ou parte dele) da nova janela.
|
|
1350
|
+
* @param {string} descriptionToAction Descrição da ação para relatório.
|
|
1351
|
+
* @param {boolean} [getSnapShot=false] Se deve tirar captura de tela.
|
|
1352
|
+
* @returns {Promise<typeof WebActions>} Retorna a classe para encadeamento.
|
|
1353
|
+
* @throws {Error} Se a janela com o título especificado não for encontrada.
|
|
1354
|
+
*
|
|
1355
|
+
* @example
|
|
1356
|
+
* await WebActions.click('#linkNovaJanela', 'Abrir nova janela', true);
|
|
1357
|
+
* await WebActions.switchToWindowByTitle('Nova Página', 'Mudar para nova janela', true);
|
|
1358
|
+
*/
|
|
1359
|
+
static switchToWindowByTitle(title: string, descriptionToAction: string, getSnapShot?: boolean): Promise<typeof WebActions>;
|
|
1360
|
+
/**
|
|
1361
|
+
* 🔙 Fecha a janela/aba atual e volta para a janela anterior.
|
|
1362
|
+
*
|
|
1363
|
+
* @param {string} descriptionToAction Descrição da ação para relatório.
|
|
1364
|
+
* @param {boolean} [getSnapShot=false] Se deve tirar captura de tela.
|
|
1365
|
+
* @returns {Promise<typeof WebActions>} Retorna a classe para encadeamento.
|
|
1366
|
+
*
|
|
1367
|
+
* @example
|
|
1368
|
+
* await WebActions.click('#linkNovaJanela', 'Abrir nova janela', true);
|
|
1369
|
+
* await WebActions.switchToWindowByUrl('http://example.com/nova', 'Mudar para nova janela', true);
|
|
1370
|
+
* // Fazer algo na nova janela...
|
|
1371
|
+
* await WebActions.closeWindowAndSwitchBack('Fechar e voltar', true);
|
|
1372
|
+
*/
|
|
1373
|
+
static closeWindowAndSwitchBack(descriptionToAction: string, getSnapShot?: boolean): Promise<typeof WebActions>;
|
|
1374
|
+
/**
|
|
1375
|
+
* 📋 Obtém a quantidade de janelas/abas abertas no contexto atual.
|
|
1376
|
+
*
|
|
1377
|
+
* @param {string} [descricao] Descrição da ação para relatório.
|
|
1378
|
+
* @returns {Promise<number>} Número de janelas abertas.
|
|
1379
|
+
*
|
|
1380
|
+
* @example
|
|
1381
|
+
* const qtdJanelas = await WebActions.getWindowCount('Verificar janelas abertas');
|
|
1382
|
+
* console.log(`Janelas abertas: ${qtdJanelas}`);
|
|
1383
|
+
*/
|
|
1384
|
+
static getWindowCount(descricao?: string): Promise<number>;
|
|
1385
|
+
/**
|
|
1386
|
+
* 🗑️ Fecha todas as abas/janelas abertas, exceto a principal.
|
|
1387
|
+
* Tenta fechar botões específicos de abas dentro da página antes de fechar as janelas do navegador.
|
|
1388
|
+
*
|
|
1389
|
+
* @param {string | ILocator} [closeTabCadenceSelector] Seletor do botão de fechar aba Cadence Builder (opcional).
|
|
1390
|
+
* @param {string | ILocator} [closeTabItemSelector] Seletor do botão de fechar aba item (opcional).
|
|
1391
|
+
* @param {number} [waitTime=1000] Tempo de espera após fechar cada aba (em ms).
|
|
1392
|
+
* @param {boolean} [getSnapShot=false] Se deve tirar captura de tela.
|
|
1393
|
+
* @returns {Promise<typeof WebActions>} Retorna a classe para encadeamento.
|
|
1394
|
+
*
|
|
1395
|
+
* @example
|
|
1396
|
+
* // Fechar todas as abas/janelas abertas
|
|
1397
|
+
* await WebActions.closeAllTabs();
|
|
1398
|
+
*
|
|
1399
|
+
* @example
|
|
1400
|
+
* // Fechar abas específicas com seletores personalizados
|
|
1401
|
+
* await WebActions.closeAllTabs(
|
|
1402
|
+
* '[data-testid="close-cadence"]',
|
|
1403
|
+
* '.close-tab-button',
|
|
1404
|
+
* 2000,
|
|
1405
|
+
* true
|
|
1406
|
+
* );
|
|
1407
|
+
*/
|
|
1408
|
+
static closeAllTabs(closeTabCadenceSelector?: string | ILocator, closeTabItemSelector?: string | ILocator, waitTime?: number, getSnapShot?: boolean): Promise<typeof WebActions>;
|
|
1409
|
+
/**
|
|
1410
|
+
* 🔍 Obtém todos os elementos que correspondem ao seletor fornecido.
|
|
1411
|
+
* Retorna um array de ILocator para todos os elementos encontrados.
|
|
1412
|
+
*
|
|
1413
|
+
* @param {string | ILocator} elemento Seletor CSS, XPath ou ILocator do elemento.
|
|
1414
|
+
* @param {string} [descricao] Descrição da ação para logs (opcional).
|
|
1415
|
+
* @returns {Promise<ILocator[]>} Array de ILocator com todos os elementos encontrados.
|
|
1416
|
+
*
|
|
1417
|
+
* @example
|
|
1418
|
+
* // Obter todos os botões na página
|
|
1419
|
+
* const botoes = await WebActions.getAllElements('button', 'Buscar todos os botões');
|
|
1420
|
+
* console.log(`Encontrados ${botoes.length} botões`);
|
|
1421
|
+
*
|
|
1422
|
+
* @example
|
|
1423
|
+
* // Obter todos os elementos de uma lista
|
|
1424
|
+
* const items = await WebActions.getAllElements('.list-item');
|
|
1425
|
+
* for (const item of items) {
|
|
1426
|
+
* const texto = await item.textContent();
|
|
1427
|
+
* console.log(texto);
|
|
1428
|
+
* }
|
|
1429
|
+
*/
|
|
1430
|
+
static getAllElements(elemento: string | ILocator, descricao?: string): Promise<ILocator[]>;
|
|
1431
|
+
/**
|
|
1432
|
+
* 🔧 Altera o innerText de um elemento via JavaScript.
|
|
1433
|
+
* Compatível com Qandalf Java: executeScript para alterar innerText.
|
|
1434
|
+
* Útil para elementos que não aceitam preenchimento normal ou labels/spans.
|
|
1435
|
+
*
|
|
1436
|
+
* @param {string | ILocator} elemento Seletor CSS/XPath ou ILocator do elemento.
|
|
1437
|
+
* @param {string} texto Texto a ser definido no innerText.
|
|
1438
|
+
* @param {string} [descricao] Descrição da ação para relatório.
|
|
1439
|
+
* @param {boolean} [tirarPrint=false] Se deve capturar captura de tela.
|
|
1440
|
+
* @returns {Promise<typeof WebActions>} Retorna a classe para encadeamento.
|
|
1441
|
+
*
|
|
1442
|
+
* @example
|
|
1443
|
+
* // Alterar texto de um label
|
|
1444
|
+
* await WebActions.setInnerText('#labelProbabilidade', '75%', 'Definir probabilidade', true);
|
|
1445
|
+
*
|
|
1446
|
+
* @example
|
|
1447
|
+
* // Uso com variável
|
|
1448
|
+
* const taxProbability = 85;
|
|
1449
|
+
* await WebActions.setInnerText(
|
|
1450
|
+
* this.selecionarProbabilidadeParceiroBeforeText,
|
|
1451
|
+
* `${taxProbability}%`,
|
|
1452
|
+
* 'Alterando probabilidade do parceiro',
|
|
1453
|
+
* true
|
|
1454
|
+
* );
|
|
1455
|
+
*/
|
|
1456
|
+
static setInnerText(elemento: string | ILocator, texto: string, descricao?: string, tirarPrint?: boolean): Promise<typeof WebActions>;
|
|
1457
|
+
/**
|
|
1458
|
+
* 🔧 Altera o innerHTML de um elemento via JavaScript.
|
|
1459
|
+
* Útil para inserir HTML dinâmico em elementos.
|
|
1460
|
+
*
|
|
1461
|
+
* @param {string | ILocator} elemento Seletor CSS/XPath ou ILocator do elemento.
|
|
1462
|
+
* @param {string} html HTML a ser definido no innerHTML.
|
|
1463
|
+
* @param {string} [descricao] Descrição da ação para relatório.
|
|
1464
|
+
* @param {boolean} [tirarPrint=false] Se deve capturar captura de tela.
|
|
1465
|
+
* @returns {Promise<typeof WebActions>} Retorna a classe para encadeamento.
|
|
1466
|
+
*
|
|
1467
|
+
* @example
|
|
1468
|
+
* await WebActions.setInnerHTML('#container', '<span class="destaque">Novo conteúdo</span>', 'Inserir HTML', true);
|
|
1469
|
+
*/
|
|
1470
|
+
static setInnerHTML(elemento: string | ILocator, html: string, descricao?: string, tirarPrint?: boolean): Promise<typeof WebActions>;
|
|
1471
|
+
/**
|
|
1472
|
+
* 🔧 Executa um script JavaScript customizado no contexto do elemento.
|
|
1473
|
+
* Compatível com Qandalf Java: executeScript genérico.
|
|
1474
|
+
*
|
|
1475
|
+
* @param {string | ILocator} elemento Seletor CSS/XPath ou ILocator do elemento.
|
|
1476
|
+
* @param {string} script Script JavaScript a ser executado. Use 'element' para referenciar o elemento.
|
|
1477
|
+
* @param {string} [descricao] Descrição da ação para relatório.
|
|
1478
|
+
* @param {boolean} [tirarPrint=false] Se deve capturar captura de tela.
|
|
1479
|
+
* @returns {Promise<unknown>} Resultado da execução do script.
|
|
1480
|
+
*
|
|
1481
|
+
* @example
|
|
1482
|
+
* // Alterar estilo do elemento
|
|
1483
|
+
* await WebActions.executeScriptOnElement('#botao', 'element.style.backgroundColor = "red"', 'Destacar botão');
|
|
1484
|
+
*
|
|
1485
|
+
* @example
|
|
1486
|
+
* // Obter propriedade do elemento
|
|
1487
|
+
* const offsetTop = await WebActions.executeScriptOnElement('#header', 'return element.offsetTop');
|
|
1488
|
+
*/
|
|
1489
|
+
static executeScriptOnElement(elemento: string | ILocator, script: string, descricao?: string, tirarPrint?: boolean): Promise<unknown>;
|
|
1490
|
+
/** Flag para controle de inicialização do extrator */
|
|
1491
|
+
private static _catalogExtractorReady;
|
|
1492
|
+
/** URLs já populadas automaticamente pelo catálogo (lazy auto-refresh, uma vez por página) */
|
|
1493
|
+
private static _catalogPopulatedPages;
|
|
1494
|
+
/**
|
|
1495
|
+
* Garante que o extrator do XPathCatalog esteja configurado.
|
|
1496
|
+
* Registra `extractBasicPageStructure` como fonte de dados.
|
|
1497
|
+
*/
|
|
1498
|
+
private static ensureCatalogExtractor;
|
|
1499
|
+
/**
|
|
1500
|
+
* Extrai a estrutura da página atual e armazena no catálogo interno.
|
|
1501
|
+
* Equivale a `extract_page_structure` do MCP, porém local via Playwright.
|
|
1502
|
+
*
|
|
1503
|
+
* @returns Estrutura bruta capturada
|
|
1504
|
+
*
|
|
1505
|
+
* @example
|
|
1506
|
+
* ```ts
|
|
1507
|
+
* const structure = await WebActions.extractPageStructure()
|
|
1508
|
+
* console.log(structure.inputs?.length, 'inputs encontrados')
|
|
1509
|
+
* ```
|
|
1510
|
+
*/
|
|
1511
|
+
static extractPageStructure(): Promise<RawPageStructure>;
|
|
1512
|
+
/**
|
|
1513
|
+
* Obtém catálogo de XPaths da página atual ou de uma página específica.
|
|
1514
|
+
*
|
|
1515
|
+
* @param opts Opções de consulta
|
|
1516
|
+
*
|
|
1517
|
+
* @example
|
|
1518
|
+
* ```ts
|
|
1519
|
+
* // Todos os XPaths da página atual
|
|
1520
|
+
* const catalog = await WebActions.getCurrentXPathCatalog()
|
|
1521
|
+
*
|
|
1522
|
+
* // Filtrar por texto
|
|
1523
|
+
* const results = await WebActions.getCurrentXPathCatalog({ filter: 'catalogo de ofertas' })
|
|
1524
|
+
*
|
|
1525
|
+
* // Forçar refresh
|
|
1526
|
+
* const fresh = await WebActions.getCurrentXPathCatalog({ refresh: true })
|
|
1527
|
+
* ```
|
|
1528
|
+
*/
|
|
1529
|
+
static getCurrentXPathCatalog(opts?: CatalogGetOptions): Promise<XPathCatalogItem[]>;
|
|
1530
|
+
/**
|
|
1531
|
+
* Obtém estrutura de XPaths da página atual (item 18 v2.7.44).
|
|
1532
|
+
*
|
|
1533
|
+
* Comportamento:
|
|
1534
|
+
* - Sem `page`: usa URL atual da sessão.
|
|
1535
|
+
* - Com `strictPage=true` (default): prioriza só XPaths da página atual.
|
|
1536
|
+
* - Se a estrutura mudar, `refresh=true` recaptura automaticamente.
|
|
1537
|
+
*
|
|
1538
|
+
* @example
|
|
1539
|
+
* ```ts
|
|
1540
|
+
* const items = await WebActions.getCurrentPageStructure()
|
|
1541
|
+
* const filtered = await WebActions.getCurrentPageStructure({ filter: 'login', refresh: true })
|
|
1542
|
+
* ```
|
|
1543
|
+
*/
|
|
1544
|
+
static getCurrentPageStructure(params?: {
|
|
1545
|
+
page?: string;
|
|
1546
|
+
filter?: string;
|
|
1547
|
+
refresh?: boolean;
|
|
1548
|
+
strictPage?: boolean;
|
|
1549
|
+
maxItems?: number;
|
|
1550
|
+
}): Promise<PageXPathItem[]>;
|
|
1551
|
+
/**
|
|
1552
|
+
* Detecta nome do arquivo de Page Object chamador a partir do stack trace.
|
|
1553
|
+
* Retorna metadados de página para enriquecer requisições de recovery.
|
|
1554
|
+
*
|
|
1555
|
+
* Regra de inferência (item 20):
|
|
1556
|
+
* - `PagePlaywrightLoginSalesforce` → pageName: `Login Salesforce`
|
|
1557
|
+
*/
|
|
1558
|
+
static getCallerPageMetadata(): {
|
|
1559
|
+
pageFileName?: string;
|
|
1560
|
+
pageName?: string;
|
|
1561
|
+
pageObjectName?: string;
|
|
1562
|
+
};
|
|
1563
|
+
/**
|
|
1564
|
+
* Detecta o arquivo de Attributes* e nome de classe/método do chamador,
|
|
1565
|
+
* usado para enriquecer auto-fix com contexto de propriedade (item 7/12).
|
|
1566
|
+
*/
|
|
1567
|
+
static getCallerAttributesContext(): {
|
|
1568
|
+
attributesFile?: string;
|
|
1569
|
+
className?: string;
|
|
1570
|
+
methodName?: string;
|
|
1571
|
+
};
|
|
1572
|
+
/**
|
|
1573
|
+
* Tenta resolver o alvo recebido (texto/label/id/name) usando o catálogo
|
|
1574
|
+
* da página atual. Se encontrar match com score >= 0.6, retorna o XPath.
|
|
1575
|
+
* Caso contrário, retorna o alvo original inalterado.
|
|
1576
|
+
*
|
|
1577
|
+
* Usado internamente antes de cada ação para aproveitar o catálogo.
|
|
1578
|
+
*/
|
|
1579
|
+
private static resolveXPathFromCatalog;
|
|
1580
|
+
/**
|
|
1581
|
+
* Captura DOM/pageStructure da página atual e envia ao backend para
|
|
1582
|
+
* processamento remoto. Usado em execuções Azure/CI onde o backend não
|
|
1583
|
+
* tem acesso de rede à URL alvo.
|
|
1584
|
+
*
|
|
1585
|
+
* O backend processa, enriquece com hints Redis e retorna catálogo.
|
|
1586
|
+
* O resultado alimenta automaticamente o cache do XPathCatalog.
|
|
1587
|
+
*
|
|
1588
|
+
* @param opts Opções extras (filtro, xpaths específicos, auth token)
|
|
1589
|
+
* @returns Resposta do backend com catálogo enriquecido
|
|
1590
|
+
*
|
|
1591
|
+
* @example
|
|
1592
|
+
* ```ts
|
|
1593
|
+
* const result = await WebActions.pushCatalogToBackend({ filter: 'cliente' })
|
|
1594
|
+
* // O catálogo já está no cache; próximos click/fill usam resolver interno
|
|
1595
|
+
* ```
|
|
1596
|
+
*/
|
|
1597
|
+
private static pushCatalogToBackend;
|
|
1598
|
+
}
|
|
1599
|
+
export {};
|