@checkly/playwright-core 1.51.17-beta.2 → 1.54.2-beta.1
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/ThirdPartyNotices.txt +65 -123
- package/browsers.json +16 -14
- package/index.js +1 -1
- package/lib/androidServerImpl.js +47 -50
- package/lib/browserServerImpl.js +89 -69
- package/lib/checkly/escapeRegExp.js +23 -27
- package/lib/checkly/fetch.js +64 -46
- package/lib/checkly/secretsFilter.js +49 -35
- package/lib/cli/driver.js +71 -69
- package/lib/cli/program.js +400 -359
- package/lib/cli/programWithTestStub.js +51 -45
- package/lib/client/accessibility.js +31 -32
- package/lib/client/android.js +151 -242
- package/lib/client/api.js +135 -283
- package/lib/client/artifact.js +39 -36
- package/lib/client/browser.js +96 -71
- package/lib/client/browserContext.js +314 -345
- package/lib/client/browserType.js +103 -127
- package/lib/client/cdpSession.js +29 -31
- package/lib/client/channelOwner.js +89 -112
- package/lib/client/clientHelper.js +48 -39
- package/lib/client/clientInstrumentation.js +40 -37
- package/lib/client/clientStackTrace.js +41 -37
- package/lib/client/clock.js +36 -36
- package/lib/client/connection.js +188 -214
- package/lib/client/consoleMessage.js +31 -28
- package/lib/client/coverage.js +25 -22
- package/lib/client/dialog.js +30 -31
- package/lib/client/download.js +25 -25
- package/lib/client/electron.js +80 -77
- package/lib/client/elementHandle.js +120 -159
- package/lib/client/errors.js +53 -53
- package/lib/client/eventEmitter.js +124 -121
- package/lib/client/events.js +72 -68
- package/lib/client/fetch.js +166 -190
- package/lib/client/fileChooser.js +25 -24
- package/lib/client/fileUtils.js +31 -28
- package/lib/client/frame.js +207 -306
- package/lib/client/harRouter.js +42 -52
- package/lib/client/input.js +42 -69
- package/lib/client/jsHandle.js +54 -69
- package/lib/client/jsonPipe.js +27 -23
- package/lib/client/localUtils.js +29 -29
- package/lib/client/locator.js +145 -237
- package/lib/client/network.js +282 -307
- package/lib/client/page.js +269 -318
- package/lib/client/platform.js +46 -43
- package/lib/client/playwright.js +51 -76
- package/lib/client/selectors.js +45 -63
- package/lib/client/stream.js +29 -25
- package/lib/client/timeoutSettings.js +55 -41
- package/lib/client/tracing.js +49 -96
- package/lib/client/types.js +26 -22
- package/lib/client/video.js +35 -27
- package/lib/client/waiter.js +69 -88
- package/lib/client/webError.js +25 -23
- package/lib/client/webSocket.js +43 -56
- package/lib/client/worker.js +48 -56
- package/lib/client/writableStream.js +27 -23
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +26 -6
- package/lib/generated/consoleApiSource.js +26 -6
- package/lib/generated/injectedScriptSource.js +26 -6
- package/lib/generated/pollingRecorderSource.js +26 -6
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +26 -6
- package/lib/generated/webSocketMockSource.js +333 -5
- package/lib/inProcessFactory.js +51 -53
- package/lib/inprocess.js +2 -19
- package/lib/outofprocess.js +51 -46
- package/lib/protocol/serializers.js +153 -134
- package/lib/protocol/validator.js +2807 -2739
- package/lib/protocol/validatorPrimitives.js +114 -73
- package/lib/remote/playwrightConnection.js +88 -242
- package/lib/remote/playwrightServer.js +305 -92
- package/lib/server/accessibility.js +44 -37
- package/lib/server/android/android.js +251 -241
- package/lib/server/android/backendAdb.js +87 -82
- package/lib/server/artifact.js +78 -55
- package/lib/server/bidi/bidiBrowser.js +297 -158
- package/lib/server/bidi/bidiChromium.js +119 -89
- package/lib/server/bidi/bidiConnection.js +66 -83
- package/lib/server/bidi/bidiExecutionContext.js +129 -113
- package/lib/server/bidi/bidiFirefox.js +86 -76
- package/lib/server/bidi/bidiInput.js +106 -117
- package/lib/server/bidi/bidiNetworkManager.js +142 -159
- package/lib/server/bidi/bidiOverCdp.js +57 -58
- package/lib/server/bidi/bidiPage.js +260 -260
- package/lib/server/bidi/bidiPdf.js +52 -86
- package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
- package/lib/server/bidi/third_party/bidiKeyboard.js +236 -220
- package/lib/server/bidi/third_party/bidiProtocol.js +22 -137
- package/lib/server/bidi/third_party/bidiProtocolCore.js +152 -0
- package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -0
- package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
- package/lib/server/bidi/third_party/firefoxPrefs.js +141 -119
- package/lib/server/browser.js +93 -95
- package/lib/server/browserContext.js +419 -429
- package/lib/server/browserType.js +186 -216
- package/lib/server/callLog.js +47 -44
- package/lib/server/chromium/chromium.js +235 -203
- package/lib/server/chromium/chromiumSwitches.js +100 -67
- package/lib/server/chromium/crAccessibility.js +157 -131
- package/lib/server/chromium/crBrowser.js +310 -292
- package/lib/server/chromium/crConnection.js +95 -121
- package/lib/server/chromium/crCoverage.js +121 -131
- package/lib/server/chromium/crDevTools.js +60 -51
- package/lib/server/chromium/crDragDrop.js +68 -84
- package/lib/server/chromium/crExecutionContext.js +89 -83
- package/lib/server/chromium/crInput.js +118 -113
- package/lib/server/chromium/crNetworkManager.js +274 -375
- package/lib/server/chromium/crPage.js +536 -593
- package/lib/server/chromium/crPdf.js +54 -86
- package/lib/server/chromium/crProtocolHelper.js +92 -80
- package/lib/server/chromium/crServiceWorker.js +84 -73
- package/lib/server/chromium/defaultFontFamilies.js +152 -135
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/chromium/videoRecorder.js +66 -99
- package/lib/server/clock.js +107 -83
- package/lib/server/codegen/csharp.js +192 -162
- package/lib/server/codegen/java.js +156 -129
- package/lib/server/codegen/javascript.js +163 -148
- package/lib/server/codegen/jsonl.js +32 -28
- package/lib/server/codegen/language.js +75 -52
- package/lib/server/codegen/languages.js +65 -27
- package/lib/server/codegen/python.js +141 -126
- package/lib/server/codegen/types.js +15 -4
- package/lib/server/console.js +28 -32
- package/lib/server/cookieStore.js +108 -86
- package/lib/server/debugController.js +147 -151
- package/lib/server/debugger.js +86 -78
- package/lib/server/deviceDescriptors.js +37 -24
- package/lib/server/deviceDescriptorsSource.json +238 -128
- package/lib/server/dialog.js +84 -39
- package/lib/server/dispatchers/androidDispatcher.js +257 -148
- package/lib/server/dispatchers/artifactDispatcher.js +79 -79
- package/lib/server/dispatchers/browserContextDispatcher.js +289 -259
- package/lib/server/dispatchers/browserDispatcher.js +96 -148
- package/lib/server/dispatchers/browserTypeDispatcher.js +50 -41
- package/lib/server/dispatchers/cdpSessionDispatcher.js +35 -39
- package/lib/server/dispatchers/debugControllerDispatcher.js +65 -83
- package/lib/server/dispatchers/dialogDispatcher.js +34 -31
- package/lib/server/dispatchers/dispatcher.js +208 -248
- package/lib/server/dispatchers/electronDispatcher.js +66 -70
- package/lib/server/dispatchers/elementHandlerDispatcher.js +164 -216
- package/lib/server/dispatchers/frameDispatcher.js +211 -272
- package/lib/server/dispatchers/jsHandleDispatcher.js +63 -75
- package/lib/server/dispatchers/jsonPipeDispatcher.js +37 -38
- package/lib/server/dispatchers/localUtilsDispatcher.js +121 -119
- package/lib/server/dispatchers/networkDispatchers.js +117 -128
- package/lib/server/dispatchers/pageDispatcher.js +256 -248
- package/lib/server/dispatchers/playwrightDispatcher.js +92 -87
- package/lib/server/dispatchers/streamDispatcher.js +52 -48
- package/lib/server/dispatchers/tracingDispatcher.js +47 -52
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +126 -150
- package/lib/server/dispatchers/writableStreamDispatcher.js +65 -43
- package/lib/server/dom.js +485 -582
- package/lib/server/download.js +47 -37
- package/lib/server/electron/electron.js +216 -243
- package/lib/server/electron/loader.js +9 -37
- package/lib/server/errors.js +47 -46
- package/lib/server/fetch.js +317 -360
- package/lib/server/fileChooser.js +25 -24
- package/lib/server/fileUploadUtils.js +66 -60
- package/lib/server/firefox/ffAccessibility.js +153 -131
- package/lib/server/firefox/ffBrowser.js +268 -305
- package/lib/server/firefox/ffConnection.js +63 -84
- package/lib/server/firefox/ffExecutionContext.js +92 -73
- package/lib/server/firefox/ffInput.js +82 -84
- package/lib/server/firefox/ffNetworkManager.js +137 -114
- package/lib/server/firefox/ffPage.js +261 -293
- package/lib/server/firefox/firefox.js +80 -72
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +107 -35
- package/lib/server/frameSelectors.js +98 -114
- package/lib/server/frames.js +845 -1055
- package/lib/server/har/harRecorder.js +85 -77
- package/lib/server/har/harTracer.js +290 -223
- package/lib/server/harBackend.js +80 -80
- package/lib/server/helper.js +55 -59
- package/lib/server/index.js +59 -99
- package/lib/server/input.js +151 -189
- package/lib/server/instrumentation.js +57 -44
- package/lib/server/javascript.js +133 -134
- package/lib/server/launchApp.js +113 -75
- package/lib/server/localUtils.js +150 -142
- package/lib/server/macEditingCommands.js +141 -137
- package/lib/server/network.js +299 -303
- package/lib/server/page.js +513 -544
- package/lib/server/pipeTransport.js +49 -45
- package/lib/server/playwright.js +58 -67
- package/lib/server/progress.js +137 -68
- package/lib/server/protocolError.js +34 -31
- package/lib/server/recorder/chat.js +70 -86
- package/lib/server/recorder/recorderApp.js +341 -176
- package/lib/server/recorder/recorderInTraceViewer.js +65 -94
- package/lib/server/recorder/recorderRunner.js +93 -116
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +104 -47
- package/lib/server/recorder/throttledFile.js +42 -30
- package/lib/server/recorder.js +395 -275
- package/lib/server/registry/browserFetcher.js +106 -101
- package/lib/server/registry/dependencies.js +245 -196
- package/lib/server/registry/index.js +930 -803
- package/lib/server/registry/nativeDeps.js +1073 -464
- package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
- package/lib/server/screenshotter.js +160 -191
- package/lib/server/selectors.js +90 -51
- package/lib/server/socksClientCertificatesInterceptor.js +171 -186
- package/lib/server/socksInterceptor.js +62 -70
- package/lib/server/trace/recorder/snapshotter.js +76 -102
- package/lib/server/trace/recorder/snapshotterInjected.js +238 -217
- package/lib/server/trace/recorder/tracing.js +354 -362
- package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
- package/lib/server/trace/viewer/traceViewer.js +160 -147
- package/lib/server/transport.js +119 -134
- package/lib/server/types.js +26 -22
- package/lib/server/usKeyboardLayout.js +135 -545
- package/lib/server/utils/ascii.js +39 -26
- package/lib/server/utils/comparators.js +105 -103
- package/lib/server/utils/crypto.js +157 -112
- package/lib/server/utils/debug.js +36 -32
- package/lib/server/utils/debugLogger.js +77 -48
- package/lib/server/utils/env.js +52 -37
- package/lib/server/utils/eventsHelper.js +29 -28
- package/lib/server/utils/expectUtils.js +31 -26
- package/lib/server/utils/fileUtils.js +123 -136
- package/lib/server/utils/happyEyeballs.js +141 -126
- package/lib/server/utils/hostPlatform.js +84 -120
- package/lib/server/utils/httpServer.js +106 -121
- package/lib/server/utils/image_tools/colorUtils.js +42 -51
- package/lib/server/utils/image_tools/compare.js +44 -43
- package/lib/server/utils/image_tools/imageChannel.js +38 -30
- package/lib/server/utils/image_tools/stats.js +40 -40
- package/lib/server/utils/linuxUtils.js +50 -37
- package/lib/server/utils/network.js +152 -96
- package/lib/server/utils/nodePlatform.js +87 -79
- package/lib/server/utils/pipeTransport.js +44 -42
- package/lib/server/utils/processLauncher.js +111 -121
- package/lib/server/utils/profiler.js +52 -39
- package/lib/server/utils/socksProxy.js +280 -339
- package/lib/server/utils/spawnAsync.js +37 -41
- package/lib/server/utils/task.js +31 -38
- package/lib/server/utils/userAgent.js +73 -66
- package/lib/server/utils/wsServer.js +68 -75
- package/lib/server/utils/zipFile.js +36 -37
- package/lib/server/utils/zones.js +37 -34
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +77 -61
- package/lib/server/webkit/wkAccessibility.js +161 -118
- package/lib/server/webkit/wkBrowser.js +193 -184
- package/lib/server/webkit/wkConnection.js +59 -83
- package/lib/server/webkit/wkExecutionContext.js +85 -70
- package/lib/server/webkit/wkInput.js +97 -95
- package/lib/server/webkit/wkInterceptableRequest.js +102 -95
- package/lib/server/webkit/wkPage.js +568 -667
- package/lib/server/webkit/wkProvisionalPage.js +45 -56
- package/lib/server/webkit/wkWorkers.js +79 -79
- package/lib/utils/expectUtils.js +31 -26
- package/lib/utils/isomorphic/ariaSnapshot.js +149 -152
- package/lib/utils/isomorphic/assert.js +28 -22
- package/lib/utils/isomorphic/colors.js +66 -59
- package/lib/utils/isomorphic/cssParser.js +120 -125
- package/lib/utils/isomorphic/cssTokenizer.js +436 -364
- package/lib/utils/isomorphic/headers.js +38 -37
- package/lib/utils/isomorphic/locatorGenerators.js +358 -357
- package/lib/utils/isomorphic/locatorParser.js +96 -105
- package/lib/utils/isomorphic/locatorUtils.js +63 -44
- package/lib/utils/isomorphic/manualPromise.js +46 -39
- package/lib/utils/isomorphic/mimeType.js +447 -25
- package/lib/utils/isomorphic/multimap.js +34 -27
- package/lib/utils/isomorphic/protocolFormatter.js +68 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +321 -0
- package/lib/utils/isomorphic/recorderUtils.js +140 -181
- package/lib/utils/isomorphic/rtti.js +35 -33
- package/lib/utils/isomorphic/selectorParser.js +182 -193
- package/lib/utils/isomorphic/semaphore.js +27 -24
- package/lib/utils/isomorphic/stackTrace.js +87 -98
- package/lib/utils/isomorphic/stringUtils.js +98 -112
- package/lib/utils/isomorphic/time.js +46 -22
- package/lib/utils/isomorphic/timeoutRunner.js +53 -53
- package/lib/utils/isomorphic/traceUtils.js +37 -41
- package/lib/utils/isomorphic/types.js +15 -4
- package/lib/utils/isomorphic/urlMatch.js +113 -67
- package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -0
- package/lib/utils.js +101 -443
- package/lib/utilsBundle.js +101 -52
- package/lib/utilsBundleImpl/index.js +160 -150
- package/lib/zipBundle.js +32 -23
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +1 -1
- package/types/protocol.d.ts +1267 -1057
- package/types/types.d.ts +131 -29
- package/lib/common/socksProxy.js +0 -569
- package/lib/common/timeoutSettings.js +0 -73
- package/lib/common/types.js +0 -5
- package/lib/image_tools/colorUtils.js +0 -98
- package/lib/image_tools/compare.js +0 -108
- package/lib/image_tools/imageChannel.js +0 -70
- package/lib/image_tools/stats.js +0 -102
- package/lib/protocol/debug.js +0 -27
- package/lib/protocol/transport.js +0 -82
- package/lib/server/dispatchers/selectorsDispatcher.js +0 -36
- package/lib/server/isomorphic/utilityScriptSerializers.js +0 -229
- package/lib/server/recorder/contextRecorder.js +0 -290
- package/lib/server/recorder/recorderCollection.js +0 -104
- package/lib/server/recorder/recorderFrontend.js +0 -5
- package/lib/server/storageScript.js +0 -160
- package/lib/server/timeoutSettings.js +0 -74
- package/lib/third_party/diff_match_patch.js +0 -2222
- package/lib/utils/ascii.js +0 -31
- package/lib/utils/comparators.js +0 -171
- package/lib/utils/crypto.js +0 -174
- package/lib/utils/debug.js +0 -46
- package/lib/utils/debugLogger.js +0 -91
- package/lib/utils/env.js +0 -49
- package/lib/utils/eventsHelper.js +0 -38
- package/lib/utils/fileUtils.js +0 -205
- package/lib/utils/happy-eyeballs.js +0 -210
- package/lib/utils/headers.js +0 -52
- package/lib/utils/hostPlatform.js +0 -133
- package/lib/utils/httpServer.js +0 -237
- package/lib/utils/index.js +0 -368
- package/lib/utils/linuxUtils.js +0 -78
- package/lib/utils/manualPromise.js +0 -109
- package/lib/utils/multimap.js +0 -75
- package/lib/utils/network.js +0 -160
- package/lib/utils/processLauncher.js +0 -248
- package/lib/utils/profiler.js +0 -53
- package/lib/utils/rtti.js +0 -44
- package/lib/utils/semaphore.js +0 -51
- package/lib/utils/spawnAsync.js +0 -45
- package/lib/utils/stackTrace.js +0 -121
- package/lib/utils/task.js +0 -58
- package/lib/utils/time.js +0 -37
- package/lib/utils/timeoutRunner.js +0 -66
- package/lib/utils/traceUtils.js +0 -44
- package/lib/utils/userAgent.js +0 -105
- package/lib/utils/wsServer.js +0 -127
- package/lib/utils/zipFile.js +0 -75
- package/lib/utils/zones.js +0 -62
- package/lib/vite/htmlReport/index.html +0 -69
- package/lib/vite/recorder/assets/codeMirrorModule-B9YMkrwa.js +0 -24
- package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +0 -1
- package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/recorder/assets/index-ELPgmkwA.js +0 -184
- package/lib/vite/recorder/assets/index-eHBmevrY.css +0 -1
- package/lib/vite/recorder/index.html +0 -29
- package/lib/vite/recorder/playwright-logo.svg +0 -9
- package/lib/vite/traceViewer/assets/codeMirrorModule-gU1OOCQO.js +0 -24
- package/lib/vite/traceViewer/assets/defaultSettingsView-B5n_FjMx.js +0 -1
- package/lib/vite/traceViewer/assets/inspectorTab-6Tru8Mn_.js +0 -235
- package/lib/vite/traceViewer/assets/workbench-B_Nj4NA2.js +0 -25
- package/lib/vite/traceViewer/assets/xtermModule-BoAIEibi.js +0 -9
- package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +0 -1
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/defaultSettingsView.CO3FR0CX.css +0 -1
- package/lib/vite/traceViewer/embedded.DpNPH6mk.js +0 -2
- package/lib/vite/traceViewer/embedded.html +0 -18
- package/lib/vite/traceViewer/embedded.mLhjB5IF.css +0 -1
- package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
- package/lib/vite/traceViewer/index.CuE3SYGw.js +0 -2
- package/lib/vite/traceViewer/index.html +0 -47
- package/lib/vite/traceViewer/inspectorTab.CXDulcFG.css +0 -1
- package/lib/vite/traceViewer/playwright-logo.svg +0 -9
- package/lib/vite/traceViewer/recorder.BD-uZJs7.js +0 -2
- package/lib/vite/traceViewer/recorder.html +0 -17
- package/lib/vite/traceViewer/recorder.tn0RQdqM.css +0 -0
- package/lib/vite/traceViewer/snapshot.html +0 -21
- package/lib/vite/traceViewer/sw.bundle.js +0 -3
- package/lib/vite/traceViewer/uiMode.BatfzHMG.css +0 -1
- package/lib/vite/traceViewer/uiMode.DHrNgddz.js +0 -5
- package/lib/vite/traceViewer/uiMode.html +0 -21
- package/lib/vite/traceViewer/workbench.B9vIAzH9.css +0 -1
- package/lib/vite/traceViewer/xtermModule.Beg8tuEN.css +0 -32
|
@@ -1,249 +1,228 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var locatorGenerators_exports = {};
|
|
20
|
+
__export(locatorGenerators_exports, {
|
|
21
|
+
CSharpLocatorFactory: () => CSharpLocatorFactory,
|
|
22
|
+
JavaLocatorFactory: () => JavaLocatorFactory,
|
|
23
|
+
JavaScriptLocatorFactory: () => JavaScriptLocatorFactory,
|
|
24
|
+
JsonlLocatorFactory: () => JsonlLocatorFactory,
|
|
25
|
+
PythonLocatorFactory: () => PythonLocatorFactory,
|
|
26
|
+
asLocator: () => asLocator,
|
|
27
|
+
asLocatorDescription: () => asLocatorDescription,
|
|
28
|
+
asLocators: () => asLocators
|
|
5
29
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* See the License for the specific language governing permissions and
|
|
24
|
-
* limitations under the License.
|
|
25
|
-
*/
|
|
26
|
-
|
|
30
|
+
module.exports = __toCommonJS(locatorGenerators_exports);
|
|
31
|
+
var import_selectorParser = require("./selectorParser");
|
|
32
|
+
var import_stringUtils = require("./stringUtils");
|
|
33
|
+
function asLocatorDescription(lang, selector) {
|
|
34
|
+
try {
|
|
35
|
+
const parsed = (0, import_selectorParser.parseSelector)(selector);
|
|
36
|
+
const lastPart = parsed.parts[parsed.parts.length - 1];
|
|
37
|
+
if (lastPart?.name === "internal:describe") {
|
|
38
|
+
const description = JSON.parse(lastPart.body);
|
|
39
|
+
if (typeof description === "string")
|
|
40
|
+
return description;
|
|
41
|
+
}
|
|
42
|
+
return innerAsLocators(new generators[lang](), parsed, false, 1)[0];
|
|
43
|
+
} catch (e) {
|
|
44
|
+
return selector;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
27
47
|
function asLocator(lang, selector, isFrameLocator = false) {
|
|
28
48
|
return asLocators(lang, selector, isFrameLocator, 1)[0];
|
|
29
49
|
}
|
|
30
50
|
function asLocators(lang, selector, isFrameLocator = false, maxOutputSize = 20, preferredQuote) {
|
|
31
51
|
try {
|
|
32
|
-
return innerAsLocators(new generators[lang](preferredQuote), (0,
|
|
52
|
+
return innerAsLocators(new generators[lang](preferredQuote), (0, import_selectorParser.parseSelector)(selector), isFrameLocator, maxOutputSize);
|
|
33
53
|
} catch (e) {
|
|
34
|
-
// Tolerate invalid input.
|
|
35
54
|
return [selector];
|
|
36
55
|
}
|
|
37
56
|
}
|
|
38
57
|
function innerAsLocators(factory, parsed, isFrameLocator = false, maxOutputSize = 20) {
|
|
39
58
|
const parts = [...parsed.parts];
|
|
40
59
|
const tokens = [];
|
|
41
|
-
let nextBase = isFrameLocator ?
|
|
60
|
+
let nextBase = isFrameLocator ? "frame-locator" : "page";
|
|
42
61
|
for (let index = 0; index < parts.length; index++) {
|
|
43
62
|
const part = parts[index];
|
|
44
63
|
const base = nextBase;
|
|
45
|
-
nextBase =
|
|
46
|
-
if (part.name ===
|
|
47
|
-
|
|
64
|
+
nextBase = "locator";
|
|
65
|
+
if (part.name === "internal:describe")
|
|
66
|
+
continue;
|
|
67
|
+
if (part.name === "nth") {
|
|
68
|
+
if (part.body === "0")
|
|
69
|
+
tokens.push([factory.generateLocator(base, "first", ""), factory.generateLocator(base, "nth", "0")]);
|
|
70
|
+
else if (part.body === "-1")
|
|
71
|
+
tokens.push([factory.generateLocator(base, "last", ""), factory.generateLocator(base, "nth", "-1")]);
|
|
72
|
+
else
|
|
73
|
+
tokens.push([factory.generateLocator(base, "nth", part.body)]);
|
|
48
74
|
continue;
|
|
49
75
|
}
|
|
50
|
-
if (part.name ===
|
|
51
|
-
tokens.push([factory.generateLocator(base,
|
|
76
|
+
if (part.name === "visible") {
|
|
77
|
+
tokens.push([factory.generateLocator(base, "visible", part.body), factory.generateLocator(base, "default", `visible=${part.body}`)]);
|
|
52
78
|
continue;
|
|
53
79
|
}
|
|
54
|
-
if (part.name ===
|
|
55
|
-
const {
|
|
56
|
-
|
|
57
|
-
text
|
|
58
|
-
} = detectExact(part.body);
|
|
59
|
-
tokens.push([factory.generateLocator(base, 'text', text, {
|
|
60
|
-
exact
|
|
61
|
-
})]);
|
|
80
|
+
if (part.name === "internal:text") {
|
|
81
|
+
const { exact, text } = detectExact(part.body);
|
|
82
|
+
tokens.push([factory.generateLocator(base, "text", text, { exact })]);
|
|
62
83
|
continue;
|
|
63
84
|
}
|
|
64
|
-
if (part.name ===
|
|
65
|
-
const {
|
|
66
|
-
exact,
|
|
67
|
-
text
|
|
68
|
-
} = detectExact(part.body);
|
|
69
|
-
// There is no locator equivalent for strict has-text, leave it as is.
|
|
85
|
+
if (part.name === "internal:has-text") {
|
|
86
|
+
const { exact, text } = detectExact(part.body);
|
|
70
87
|
if (!exact) {
|
|
71
|
-
tokens.push([factory.generateLocator(base,
|
|
72
|
-
exact
|
|
73
|
-
})]);
|
|
88
|
+
tokens.push([factory.generateLocator(base, "has-text", text, { exact })]);
|
|
74
89
|
continue;
|
|
75
90
|
}
|
|
76
91
|
}
|
|
77
|
-
if (part.name ===
|
|
78
|
-
const {
|
|
79
|
-
exact,
|
|
80
|
-
text
|
|
81
|
-
} = detectExact(part.body);
|
|
82
|
-
// There is no locator equivalent for strict has-not-text, leave it as is.
|
|
92
|
+
if (part.name === "internal:has-not-text") {
|
|
93
|
+
const { exact, text } = detectExact(part.body);
|
|
83
94
|
if (!exact) {
|
|
84
|
-
tokens.push([factory.generateLocator(base,
|
|
85
|
-
exact
|
|
86
|
-
})]);
|
|
95
|
+
tokens.push([factory.generateLocator(base, "has-not-text", text, { exact })]);
|
|
87
96
|
continue;
|
|
88
97
|
}
|
|
89
98
|
}
|
|
90
|
-
if (part.name ===
|
|
99
|
+
if (part.name === "internal:has") {
|
|
91
100
|
const inners = innerAsLocators(factory, part.body.parsed, false, maxOutputSize);
|
|
92
|
-
tokens.push(inners.map(inner => factory.generateLocator(base,
|
|
101
|
+
tokens.push(inners.map((inner) => factory.generateLocator(base, "has", inner)));
|
|
93
102
|
continue;
|
|
94
103
|
}
|
|
95
|
-
if (part.name ===
|
|
104
|
+
if (part.name === "internal:has-not") {
|
|
96
105
|
const inners = innerAsLocators(factory, part.body.parsed, false, maxOutputSize);
|
|
97
|
-
tokens.push(inners.map(inner => factory.generateLocator(base,
|
|
106
|
+
tokens.push(inners.map((inner) => factory.generateLocator(base, "hasNot", inner)));
|
|
98
107
|
continue;
|
|
99
108
|
}
|
|
100
|
-
if (part.name ===
|
|
109
|
+
if (part.name === "internal:and") {
|
|
101
110
|
const inners = innerAsLocators(factory, part.body.parsed, false, maxOutputSize);
|
|
102
|
-
tokens.push(inners.map(inner => factory.generateLocator(base,
|
|
111
|
+
tokens.push(inners.map((inner) => factory.generateLocator(base, "and", inner)));
|
|
103
112
|
continue;
|
|
104
113
|
}
|
|
105
|
-
if (part.name ===
|
|
114
|
+
if (part.name === "internal:or") {
|
|
106
115
|
const inners = innerAsLocators(factory, part.body.parsed, false, maxOutputSize);
|
|
107
|
-
tokens.push(inners.map(inner => factory.generateLocator(base,
|
|
116
|
+
tokens.push(inners.map((inner) => factory.generateLocator(base, "or", inner)));
|
|
108
117
|
continue;
|
|
109
118
|
}
|
|
110
|
-
if (part.name ===
|
|
119
|
+
if (part.name === "internal:chain") {
|
|
111
120
|
const inners = innerAsLocators(factory, part.body.parsed, false, maxOutputSize);
|
|
112
|
-
tokens.push(inners.map(inner => factory.generateLocator(base,
|
|
121
|
+
tokens.push(inners.map((inner) => factory.generateLocator(base, "chain", inner)));
|
|
113
122
|
continue;
|
|
114
123
|
}
|
|
115
|
-
if (part.name ===
|
|
116
|
-
const {
|
|
117
|
-
|
|
118
|
-
text
|
|
119
|
-
} = detectExact(part.body);
|
|
120
|
-
tokens.push([factory.generateLocator(base, 'label', text, {
|
|
121
|
-
exact
|
|
122
|
-
})]);
|
|
124
|
+
if (part.name === "internal:label") {
|
|
125
|
+
const { exact, text } = detectExact(part.body);
|
|
126
|
+
tokens.push([factory.generateLocator(base, "label", text, { exact })]);
|
|
123
127
|
continue;
|
|
124
128
|
}
|
|
125
|
-
if (part.name ===
|
|
126
|
-
const attrSelector = (0,
|
|
127
|
-
const options = {
|
|
128
|
-
attrs: []
|
|
129
|
-
};
|
|
129
|
+
if (part.name === "internal:role") {
|
|
130
|
+
const attrSelector = (0, import_selectorParser.parseAttributeSelector)(part.body, true);
|
|
131
|
+
const options = { attrs: [] };
|
|
130
132
|
for (const attr of attrSelector.attributes) {
|
|
131
|
-
if (attr.name ===
|
|
133
|
+
if (attr.name === "name") {
|
|
132
134
|
options.exact = attr.caseSensitive;
|
|
133
135
|
options.name = attr.value;
|
|
134
136
|
} else {
|
|
135
|
-
if (attr.name ===
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
value: attr.value
|
|
139
|
-
});
|
|
137
|
+
if (attr.name === "level" && typeof attr.value === "string")
|
|
138
|
+
attr.value = +attr.value;
|
|
139
|
+
options.attrs.push({ name: attr.name === "include-hidden" ? "includeHidden" : attr.name, value: attr.value });
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
tokens.push([factory.generateLocator(base,
|
|
142
|
+
tokens.push([factory.generateLocator(base, "role", attrSelector.name, options)]);
|
|
143
143
|
continue;
|
|
144
144
|
}
|
|
145
|
-
if (part.name ===
|
|
146
|
-
const attrSelector = (0,
|
|
147
|
-
const {
|
|
148
|
-
|
|
149
|
-
} = attrSelector.attributes[0];
|
|
150
|
-
tokens.push([factory.generateLocator(base, 'test-id', value)]);
|
|
145
|
+
if (part.name === "internal:testid") {
|
|
146
|
+
const attrSelector = (0, import_selectorParser.parseAttributeSelector)(part.body, true);
|
|
147
|
+
const { value } = attrSelector.attributes[0];
|
|
148
|
+
tokens.push([factory.generateLocator(base, "test-id", value)]);
|
|
151
149
|
continue;
|
|
152
150
|
}
|
|
153
|
-
if (part.name ===
|
|
154
|
-
const attrSelector = (0,
|
|
155
|
-
const {
|
|
156
|
-
name,
|
|
157
|
-
value,
|
|
158
|
-
caseSensitive
|
|
159
|
-
} = attrSelector.attributes[0];
|
|
151
|
+
if (part.name === "internal:attr") {
|
|
152
|
+
const attrSelector = (0, import_selectorParser.parseAttributeSelector)(part.body, true);
|
|
153
|
+
const { name, value, caseSensitive } = attrSelector.attributes[0];
|
|
160
154
|
const text = value;
|
|
161
155
|
const exact = !!caseSensitive;
|
|
162
|
-
if (name ===
|
|
163
|
-
tokens.push([factory.generateLocator(base,
|
|
164
|
-
exact
|
|
165
|
-
})]);
|
|
156
|
+
if (name === "placeholder") {
|
|
157
|
+
tokens.push([factory.generateLocator(base, "placeholder", text, { exact })]);
|
|
166
158
|
continue;
|
|
167
159
|
}
|
|
168
|
-
if (name ===
|
|
169
|
-
tokens.push([factory.generateLocator(base,
|
|
170
|
-
exact
|
|
171
|
-
})]);
|
|
160
|
+
if (name === "alt") {
|
|
161
|
+
tokens.push([factory.generateLocator(base, "alt", text, { exact })]);
|
|
172
162
|
continue;
|
|
173
163
|
}
|
|
174
|
-
if (name ===
|
|
175
|
-
tokens.push([factory.generateLocator(base,
|
|
176
|
-
exact
|
|
177
|
-
})]);
|
|
164
|
+
if (name === "title") {
|
|
165
|
+
tokens.push([factory.generateLocator(base, "title", text, { exact })]);
|
|
178
166
|
continue;
|
|
179
167
|
}
|
|
180
168
|
}
|
|
181
|
-
if (part.name ===
|
|
182
|
-
// transform last tokens from `${selector}` into `${selector}.contentFrame()` and `frameLocator(${selector})`
|
|
169
|
+
if (part.name === "internal:control" && part.body === "enter-frame") {
|
|
183
170
|
const lastTokens = tokens[tokens.length - 1];
|
|
184
171
|
const lastPart = parts[index - 1];
|
|
185
|
-
const transformed = lastTokens.map(token => factory.chainLocators([token, factory.generateLocator(base,
|
|
186
|
-
if ([
|
|
187
|
-
transformed.push(
|
|
188
|
-
parts: [lastPart]
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}, true)));
|
|
172
|
+
const transformed = lastTokens.map((token) => factory.chainLocators([token, factory.generateLocator(base, "frame", "")]));
|
|
173
|
+
if (["xpath", "css"].includes(lastPart.name)) {
|
|
174
|
+
transformed.push(
|
|
175
|
+
factory.generateLocator(base, "frame-locator", (0, import_selectorParser.stringifySelector)({ parts: [lastPart] })),
|
|
176
|
+
factory.generateLocator(base, "frame-locator", (0, import_selectorParser.stringifySelector)({ parts: [lastPart] }, true))
|
|
177
|
+
);
|
|
192
178
|
}
|
|
193
179
|
lastTokens.splice(0, lastTokens.length, ...transformed);
|
|
194
|
-
nextBase =
|
|
180
|
+
nextBase = "frame-locator";
|
|
195
181
|
continue;
|
|
196
182
|
}
|
|
197
183
|
const nextPart = parts[index + 1];
|
|
198
|
-
const selectorPart = (0,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (nextPart && ['internal:has-text', 'internal:has-not-text'].includes(nextPart.name)) {
|
|
203
|
-
const {
|
|
204
|
-
exact,
|
|
205
|
-
text
|
|
206
|
-
} = detectExact(nextPart.body);
|
|
207
|
-
// There is no locator equivalent for strict has-text and has-not-text, leave it as is.
|
|
184
|
+
const selectorPart = (0, import_selectorParser.stringifySelector)({ parts: [part] });
|
|
185
|
+
const locatorPart = factory.generateLocator(base, "default", selectorPart);
|
|
186
|
+
if (nextPart && ["internal:has-text", "internal:has-not-text"].includes(nextPart.name)) {
|
|
187
|
+
const { exact, text } = detectExact(nextPart.body);
|
|
208
188
|
if (!exact) {
|
|
209
|
-
const nextLocatorPart = factory.generateLocator(
|
|
210
|
-
exact
|
|
211
|
-
});
|
|
189
|
+
const nextLocatorPart = factory.generateLocator("locator", nextPart.name === "internal:has-text" ? "has-text" : "has-not-text", text, { exact });
|
|
212
190
|
const options = {};
|
|
213
|
-
if (nextPart.name ===
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
191
|
+
if (nextPart.name === "internal:has-text")
|
|
192
|
+
options.hasText = text;
|
|
193
|
+
else
|
|
194
|
+
options.hasNotText = text;
|
|
195
|
+
const combinedPart = factory.generateLocator(base, "default", selectorPart, options);
|
|
218
196
|
tokens.push([factory.chainLocators([locatorPart, nextLocatorPart]), combinedPart]);
|
|
219
197
|
index++;
|
|
220
198
|
continue;
|
|
221
199
|
}
|
|
222
200
|
}
|
|
223
|
-
|
|
224
|
-
// Selectors can be prefixed with engine name, e.g. xpath=//foo
|
|
225
201
|
let locatorPartWithEngine;
|
|
226
|
-
if ([
|
|
227
|
-
const
|
|
228
|
-
parts: [part]
|
|
229
|
-
|
|
230
|
-
|
|
202
|
+
if (["xpath", "css"].includes(part.name)) {
|
|
203
|
+
const selectorPart2 = (0, import_selectorParser.stringifySelector)(
|
|
204
|
+
{ parts: [part] },
|
|
205
|
+
/* forceEngineName */
|
|
206
|
+
true
|
|
207
|
+
);
|
|
208
|
+
locatorPartWithEngine = factory.generateLocator(base, "default", selectorPart2);
|
|
231
209
|
}
|
|
232
210
|
tokens.push([locatorPart, locatorPartWithEngine].filter(Boolean));
|
|
233
211
|
}
|
|
234
212
|
return combineTokens(factory, tokens, maxOutputSize);
|
|
235
213
|
}
|
|
236
214
|
function combineTokens(factory, tokens, maxOutputSize) {
|
|
237
|
-
const currentTokens = tokens.map(() =>
|
|
215
|
+
const currentTokens = tokens.map(() => "");
|
|
238
216
|
const result = [];
|
|
239
|
-
const visit = index => {
|
|
217
|
+
const visit = (index) => {
|
|
240
218
|
if (index === tokens.length) {
|
|
241
219
|
result.push(factory.chainLocators(currentTokens));
|
|
242
220
|
return result.length < maxOutputSize;
|
|
243
221
|
}
|
|
244
222
|
for (const taken of tokens[index]) {
|
|
245
223
|
currentTokens[index] = taken;
|
|
246
|
-
if (!visit(index + 1))
|
|
224
|
+
if (!visit(index + 1))
|
|
225
|
+
return false;
|
|
247
226
|
}
|
|
248
227
|
return true;
|
|
249
228
|
};
|
|
@@ -253,9 +232,8 @@ function combineTokens(factory, tokens, maxOutputSize) {
|
|
|
253
232
|
function detectExact(text) {
|
|
254
233
|
let exact = false;
|
|
255
234
|
const match = text.match(/^\/(.*)\/([igm]*)$/);
|
|
256
|
-
if (match)
|
|
257
|
-
text: new RegExp(match[1], match[2])
|
|
258
|
-
};
|
|
235
|
+
if (match)
|
|
236
|
+
return { text: new RegExp(match[1], match[2]) };
|
|
259
237
|
if (text.endsWith('"')) {
|
|
260
238
|
text = JSON.parse(text);
|
|
261
239
|
exact = true;
|
|
@@ -266,10 +244,7 @@ function detectExact(text) {
|
|
|
266
244
|
text = JSON.parse(text.substring(0, text.length - 1));
|
|
267
245
|
exact = false;
|
|
268
246
|
}
|
|
269
|
-
return {
|
|
270
|
-
exact,
|
|
271
|
-
text
|
|
272
|
-
};
|
|
247
|
+
return { exact, text };
|
|
273
248
|
}
|
|
274
249
|
class JavaScriptLocatorFactory {
|
|
275
250
|
constructor(preferredQuote) {
|
|
@@ -277,374 +252,389 @@ class JavaScriptLocatorFactory {
|
|
|
277
252
|
}
|
|
278
253
|
generateLocator(base, kind, body, options = {}) {
|
|
279
254
|
switch (kind) {
|
|
280
|
-
case
|
|
281
|
-
if (options.hasText !==
|
|
282
|
-
|
|
255
|
+
case "default":
|
|
256
|
+
if (options.hasText !== void 0)
|
|
257
|
+
return `locator(${this.quote(body)}, { hasText: ${this.toHasText(options.hasText)} })`;
|
|
258
|
+
if (options.hasNotText !== void 0)
|
|
259
|
+
return `locator(${this.quote(body)}, { hasNotText: ${this.toHasText(options.hasNotText)} })`;
|
|
283
260
|
return `locator(${this.quote(body)})`;
|
|
284
|
-
case
|
|
261
|
+
case "frame-locator":
|
|
285
262
|
return `frameLocator(${this.quote(body)})`;
|
|
286
|
-
case
|
|
263
|
+
case "frame":
|
|
287
264
|
return `contentFrame()`;
|
|
288
|
-
case
|
|
265
|
+
case "nth":
|
|
289
266
|
return `nth(${body})`;
|
|
290
|
-
case
|
|
267
|
+
case "first":
|
|
291
268
|
return `first()`;
|
|
292
|
-
case
|
|
269
|
+
case "last":
|
|
293
270
|
return `last()`;
|
|
294
|
-
case
|
|
295
|
-
return `filter({ visible: ${body ===
|
|
296
|
-
case
|
|
271
|
+
case "visible":
|
|
272
|
+
return `filter({ visible: ${body === "true" ? "true" : "false"} })`;
|
|
273
|
+
case "role":
|
|
297
274
|
const attrs = [];
|
|
298
275
|
if (isRegExp(options.name)) {
|
|
299
276
|
attrs.push(`name: ${this.regexToSourceString(options.name)}`);
|
|
300
|
-
} else if (typeof options.name ===
|
|
277
|
+
} else if (typeof options.name === "string") {
|
|
301
278
|
attrs.push(`name: ${this.quote(options.name)}`);
|
|
302
|
-
if (options.exact)
|
|
279
|
+
if (options.exact)
|
|
280
|
+
attrs.push(`exact: true`);
|
|
303
281
|
}
|
|
304
|
-
for (const {
|
|
305
|
-
name
|
|
306
|
-
|
|
307
|
-
} of options.attrs) attrs.push(`${name}: ${typeof value === 'string' ? this.quote(value) : value}`);
|
|
308
|
-
const attrString = attrs.length ? `, { ${attrs.join(', ')} }` : '';
|
|
282
|
+
for (const { name, value } of options.attrs)
|
|
283
|
+
attrs.push(`${name}: ${typeof value === "string" ? this.quote(value) : value}`);
|
|
284
|
+
const attrString = attrs.length ? `, { ${attrs.join(", ")} }` : "";
|
|
309
285
|
return `getByRole(${this.quote(body)}${attrString})`;
|
|
310
|
-
case
|
|
286
|
+
case "has-text":
|
|
311
287
|
return `filter({ hasText: ${this.toHasText(body)} })`;
|
|
312
|
-
case
|
|
288
|
+
case "has-not-text":
|
|
313
289
|
return `filter({ hasNotText: ${this.toHasText(body)} })`;
|
|
314
|
-
case
|
|
290
|
+
case "has":
|
|
315
291
|
return `filter({ has: ${body} })`;
|
|
316
|
-
case
|
|
292
|
+
case "hasNot":
|
|
317
293
|
return `filter({ hasNot: ${body} })`;
|
|
318
|
-
case
|
|
294
|
+
case "and":
|
|
319
295
|
return `and(${body})`;
|
|
320
|
-
case
|
|
296
|
+
case "or":
|
|
321
297
|
return `or(${body})`;
|
|
322
|
-
case
|
|
298
|
+
case "chain":
|
|
323
299
|
return `locator(${body})`;
|
|
324
|
-
case
|
|
300
|
+
case "test-id":
|
|
325
301
|
return `getByTestId(${this.toTestIdValue(body)})`;
|
|
326
|
-
case
|
|
327
|
-
return this.toCallWithExact(
|
|
328
|
-
case
|
|
329
|
-
return this.toCallWithExact(
|
|
330
|
-
case
|
|
331
|
-
return this.toCallWithExact(
|
|
332
|
-
case
|
|
333
|
-
return this.toCallWithExact(
|
|
334
|
-
case
|
|
335
|
-
return this.toCallWithExact(
|
|
302
|
+
case "text":
|
|
303
|
+
return this.toCallWithExact("getByText", body, !!options.exact);
|
|
304
|
+
case "alt":
|
|
305
|
+
return this.toCallWithExact("getByAltText", body, !!options.exact);
|
|
306
|
+
case "placeholder":
|
|
307
|
+
return this.toCallWithExact("getByPlaceholder", body, !!options.exact);
|
|
308
|
+
case "label":
|
|
309
|
+
return this.toCallWithExact("getByLabel", body, !!options.exact);
|
|
310
|
+
case "title":
|
|
311
|
+
return this.toCallWithExact("getByTitle", body, !!options.exact);
|
|
336
312
|
default:
|
|
337
|
-
throw new Error(
|
|
313
|
+
throw new Error("Unknown selector kind " + kind);
|
|
338
314
|
}
|
|
339
315
|
}
|
|
340
316
|
chainLocators(locators) {
|
|
341
|
-
return locators.join(
|
|
317
|
+
return locators.join(".");
|
|
342
318
|
}
|
|
343
319
|
regexToSourceString(re) {
|
|
344
|
-
return (0,
|
|
320
|
+
return (0, import_stringUtils.normalizeEscapedRegexQuotes)(String(re));
|
|
345
321
|
}
|
|
346
322
|
toCallWithExact(method, body, exact) {
|
|
347
|
-
if (isRegExp(body))
|
|
323
|
+
if (isRegExp(body))
|
|
324
|
+
return `${method}(${this.regexToSourceString(body)})`;
|
|
348
325
|
return exact ? `${method}(${this.quote(body)}, { exact: true })` : `${method}(${this.quote(body)})`;
|
|
349
326
|
}
|
|
350
327
|
toHasText(body) {
|
|
351
|
-
if (isRegExp(body))
|
|
328
|
+
if (isRegExp(body))
|
|
329
|
+
return this.regexToSourceString(body);
|
|
352
330
|
return this.quote(body);
|
|
353
331
|
}
|
|
354
332
|
toTestIdValue(value) {
|
|
355
|
-
if (isRegExp(value))
|
|
333
|
+
if (isRegExp(value))
|
|
334
|
+
return this.regexToSourceString(value);
|
|
356
335
|
return this.quote(value);
|
|
357
336
|
}
|
|
358
337
|
quote(text) {
|
|
359
|
-
|
|
360
|
-
return (0, _stringUtils.escapeWithQuotes)(text, (_this$preferredQuote = this.preferredQuote) !== null && _this$preferredQuote !== void 0 ? _this$preferredQuote : '\'');
|
|
338
|
+
return (0, import_stringUtils.escapeWithQuotes)(text, this.preferredQuote ?? "'");
|
|
361
339
|
}
|
|
362
340
|
}
|
|
363
|
-
exports.JavaScriptLocatorFactory = JavaScriptLocatorFactory;
|
|
364
341
|
class PythonLocatorFactory {
|
|
365
342
|
generateLocator(base, kind, body, options = {}) {
|
|
366
343
|
switch (kind) {
|
|
367
|
-
case
|
|
368
|
-
if (options.hasText !==
|
|
369
|
-
|
|
344
|
+
case "default":
|
|
345
|
+
if (options.hasText !== void 0)
|
|
346
|
+
return `locator(${this.quote(body)}, has_text=${this.toHasText(options.hasText)})`;
|
|
347
|
+
if (options.hasNotText !== void 0)
|
|
348
|
+
return `locator(${this.quote(body)}, has_not_text=${this.toHasText(options.hasNotText)})`;
|
|
370
349
|
return `locator(${this.quote(body)})`;
|
|
371
|
-
case
|
|
350
|
+
case "frame-locator":
|
|
372
351
|
return `frame_locator(${this.quote(body)})`;
|
|
373
|
-
case
|
|
352
|
+
case "frame":
|
|
374
353
|
return `content_frame`;
|
|
375
|
-
case
|
|
354
|
+
case "nth":
|
|
376
355
|
return `nth(${body})`;
|
|
377
|
-
case
|
|
356
|
+
case "first":
|
|
378
357
|
return `first`;
|
|
379
|
-
case
|
|
358
|
+
case "last":
|
|
380
359
|
return `last`;
|
|
381
|
-
case
|
|
382
|
-
return `filter(visible=${body ===
|
|
383
|
-
case
|
|
360
|
+
case "visible":
|
|
361
|
+
return `filter(visible=${body === "true" ? "True" : "False"})`;
|
|
362
|
+
case "role":
|
|
384
363
|
const attrs = [];
|
|
385
364
|
if (isRegExp(options.name)) {
|
|
386
365
|
attrs.push(`name=${this.regexToString(options.name)}`);
|
|
387
|
-
} else if (typeof options.name ===
|
|
366
|
+
} else if (typeof options.name === "string") {
|
|
388
367
|
attrs.push(`name=${this.quote(options.name)}`);
|
|
389
|
-
if (options.exact)
|
|
368
|
+
if (options.exact)
|
|
369
|
+
attrs.push(`exact=True`);
|
|
390
370
|
}
|
|
391
|
-
for (const {
|
|
392
|
-
|
|
393
|
-
value
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if (typeof value === 'boolean') valueString = value ? 'True' : 'False';
|
|
397
|
-
attrs.push(`${(0, _stringUtils.toSnakeCase)(name)}=${valueString}`);
|
|
371
|
+
for (const { name, value } of options.attrs) {
|
|
372
|
+
let valueString = typeof value === "string" ? this.quote(value) : value;
|
|
373
|
+
if (typeof value === "boolean")
|
|
374
|
+
valueString = value ? "True" : "False";
|
|
375
|
+
attrs.push(`${(0, import_stringUtils.toSnakeCase)(name)}=${valueString}`);
|
|
398
376
|
}
|
|
399
|
-
const attrString = attrs.length ? `, ${attrs.join(
|
|
377
|
+
const attrString = attrs.length ? `, ${attrs.join(", ")}` : "";
|
|
400
378
|
return `get_by_role(${this.quote(body)}${attrString})`;
|
|
401
|
-
case
|
|
379
|
+
case "has-text":
|
|
402
380
|
return `filter(has_text=${this.toHasText(body)})`;
|
|
403
|
-
case
|
|
381
|
+
case "has-not-text":
|
|
404
382
|
return `filter(has_not_text=${this.toHasText(body)})`;
|
|
405
|
-
case
|
|
383
|
+
case "has":
|
|
406
384
|
return `filter(has=${body})`;
|
|
407
|
-
case
|
|
385
|
+
case "hasNot":
|
|
408
386
|
return `filter(has_not=${body})`;
|
|
409
|
-
case
|
|
387
|
+
case "and":
|
|
410
388
|
return `and_(${body})`;
|
|
411
|
-
case
|
|
389
|
+
case "or":
|
|
412
390
|
return `or_(${body})`;
|
|
413
|
-
case
|
|
391
|
+
case "chain":
|
|
414
392
|
return `locator(${body})`;
|
|
415
|
-
case
|
|
393
|
+
case "test-id":
|
|
416
394
|
return `get_by_test_id(${this.toTestIdValue(body)})`;
|
|
417
|
-
case
|
|
418
|
-
return this.toCallWithExact(
|
|
419
|
-
case
|
|
420
|
-
return this.toCallWithExact(
|
|
421
|
-
case
|
|
422
|
-
return this.toCallWithExact(
|
|
423
|
-
case
|
|
424
|
-
return this.toCallWithExact(
|
|
425
|
-
case
|
|
426
|
-
return this.toCallWithExact(
|
|
395
|
+
case "text":
|
|
396
|
+
return this.toCallWithExact("get_by_text", body, !!options.exact);
|
|
397
|
+
case "alt":
|
|
398
|
+
return this.toCallWithExact("get_by_alt_text", body, !!options.exact);
|
|
399
|
+
case "placeholder":
|
|
400
|
+
return this.toCallWithExact("get_by_placeholder", body, !!options.exact);
|
|
401
|
+
case "label":
|
|
402
|
+
return this.toCallWithExact("get_by_label", body, !!options.exact);
|
|
403
|
+
case "title":
|
|
404
|
+
return this.toCallWithExact("get_by_title", body, !!options.exact);
|
|
427
405
|
default:
|
|
428
|
-
throw new Error(
|
|
406
|
+
throw new Error("Unknown selector kind " + kind);
|
|
429
407
|
}
|
|
430
408
|
}
|
|
431
409
|
chainLocators(locators) {
|
|
432
|
-
return locators.join(
|
|
410
|
+
return locators.join(".");
|
|
433
411
|
}
|
|
434
412
|
regexToString(body) {
|
|
435
|
-
const suffix = body.flags.includes(
|
|
436
|
-
return `re.compile(r"${(0,
|
|
413
|
+
const suffix = body.flags.includes("i") ? ", re.IGNORECASE" : "";
|
|
414
|
+
return `re.compile(r"${(0, import_stringUtils.normalizeEscapedRegexQuotes)(body.source).replace(/\\\//, "/").replace(/"/g, '\\"')}"${suffix})`;
|
|
437
415
|
}
|
|
438
416
|
toCallWithExact(method, body, exact) {
|
|
439
|
-
if (isRegExp(body))
|
|
440
|
-
|
|
417
|
+
if (isRegExp(body))
|
|
418
|
+
return `${method}(${this.regexToString(body)})`;
|
|
419
|
+
if (exact)
|
|
420
|
+
return `${method}(${this.quote(body)}, exact=True)`;
|
|
441
421
|
return `${method}(${this.quote(body)})`;
|
|
442
422
|
}
|
|
443
423
|
toHasText(body) {
|
|
444
|
-
if (isRegExp(body))
|
|
424
|
+
if (isRegExp(body))
|
|
425
|
+
return this.regexToString(body);
|
|
445
426
|
return `${this.quote(body)}`;
|
|
446
427
|
}
|
|
447
428
|
toTestIdValue(value) {
|
|
448
|
-
if (isRegExp(value))
|
|
429
|
+
if (isRegExp(value))
|
|
430
|
+
return this.regexToString(value);
|
|
449
431
|
return this.quote(value);
|
|
450
432
|
}
|
|
451
433
|
quote(text) {
|
|
452
|
-
return (0,
|
|
434
|
+
return (0, import_stringUtils.escapeWithQuotes)(text, '"');
|
|
453
435
|
}
|
|
454
436
|
}
|
|
455
|
-
exports.PythonLocatorFactory = PythonLocatorFactory;
|
|
456
437
|
class JavaLocatorFactory {
|
|
457
438
|
generateLocator(base, kind, body, options = {}) {
|
|
458
439
|
let clazz;
|
|
459
440
|
switch (base) {
|
|
460
|
-
case
|
|
461
|
-
clazz =
|
|
441
|
+
case "page":
|
|
442
|
+
clazz = "Page";
|
|
462
443
|
break;
|
|
463
|
-
case
|
|
464
|
-
clazz =
|
|
444
|
+
case "frame-locator":
|
|
445
|
+
clazz = "FrameLocator";
|
|
465
446
|
break;
|
|
466
|
-
case
|
|
467
|
-
clazz =
|
|
447
|
+
case "locator":
|
|
448
|
+
clazz = "Locator";
|
|
468
449
|
break;
|
|
469
450
|
}
|
|
470
451
|
switch (kind) {
|
|
471
|
-
case
|
|
472
|
-
if (options.hasText !==
|
|
473
|
-
|
|
452
|
+
case "default":
|
|
453
|
+
if (options.hasText !== void 0)
|
|
454
|
+
return `locator(${this.quote(body)}, new ${clazz}.LocatorOptions().setHasText(${this.toHasText(options.hasText)}))`;
|
|
455
|
+
if (options.hasNotText !== void 0)
|
|
456
|
+
return `locator(${this.quote(body)}, new ${clazz}.LocatorOptions().setHasNotText(${this.toHasText(options.hasNotText)}))`;
|
|
474
457
|
return `locator(${this.quote(body)})`;
|
|
475
|
-
case
|
|
458
|
+
case "frame-locator":
|
|
476
459
|
return `frameLocator(${this.quote(body)})`;
|
|
477
|
-
case
|
|
460
|
+
case "frame":
|
|
478
461
|
return `contentFrame()`;
|
|
479
|
-
case
|
|
462
|
+
case "nth":
|
|
480
463
|
return `nth(${body})`;
|
|
481
|
-
case
|
|
464
|
+
case "first":
|
|
482
465
|
return `first()`;
|
|
483
|
-
case
|
|
466
|
+
case "last":
|
|
484
467
|
return `last()`;
|
|
485
|
-
case
|
|
486
|
-
return `filter(new ${clazz}.FilterOptions().setVisible(${body ===
|
|
487
|
-
case
|
|
468
|
+
case "visible":
|
|
469
|
+
return `filter(new ${clazz}.FilterOptions().setVisible(${body === "true" ? "true" : "false"}))`;
|
|
470
|
+
case "role":
|
|
488
471
|
const attrs = [];
|
|
489
472
|
if (isRegExp(options.name)) {
|
|
490
473
|
attrs.push(`.setName(${this.regexToString(options.name)})`);
|
|
491
|
-
} else if (typeof options.name ===
|
|
474
|
+
} else if (typeof options.name === "string") {
|
|
492
475
|
attrs.push(`.setName(${this.quote(options.name)})`);
|
|
493
|
-
if (options.exact)
|
|
476
|
+
if (options.exact)
|
|
477
|
+
attrs.push(`.setExact(true)`);
|
|
494
478
|
}
|
|
495
|
-
for (const {
|
|
496
|
-
name
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
return `getByRole(AriaRole.${(0, _stringUtils.toSnakeCase)(body).toUpperCase()}${attrString})`;
|
|
501
|
-
case 'has-text':
|
|
479
|
+
for (const { name, value } of options.attrs)
|
|
480
|
+
attrs.push(`.set${(0, import_stringUtils.toTitleCase)(name)}(${typeof value === "string" ? this.quote(value) : value})`);
|
|
481
|
+
const attrString = attrs.length ? `, new ${clazz}.GetByRoleOptions()${attrs.join("")}` : "";
|
|
482
|
+
return `getByRole(AriaRole.${(0, import_stringUtils.toSnakeCase)(body).toUpperCase()}${attrString})`;
|
|
483
|
+
case "has-text":
|
|
502
484
|
return `filter(new ${clazz}.FilterOptions().setHasText(${this.toHasText(body)}))`;
|
|
503
|
-
case
|
|
485
|
+
case "has-not-text":
|
|
504
486
|
return `filter(new ${clazz}.FilterOptions().setHasNotText(${this.toHasText(body)}))`;
|
|
505
|
-
case
|
|
487
|
+
case "has":
|
|
506
488
|
return `filter(new ${clazz}.FilterOptions().setHas(${body}))`;
|
|
507
|
-
case
|
|
489
|
+
case "hasNot":
|
|
508
490
|
return `filter(new ${clazz}.FilterOptions().setHasNot(${body}))`;
|
|
509
|
-
case
|
|
491
|
+
case "and":
|
|
510
492
|
return `and(${body})`;
|
|
511
|
-
case
|
|
493
|
+
case "or":
|
|
512
494
|
return `or(${body})`;
|
|
513
|
-
case
|
|
495
|
+
case "chain":
|
|
514
496
|
return `locator(${body})`;
|
|
515
|
-
case
|
|
497
|
+
case "test-id":
|
|
516
498
|
return `getByTestId(${this.toTestIdValue(body)})`;
|
|
517
|
-
case
|
|
518
|
-
return this.toCallWithExact(clazz,
|
|
519
|
-
case
|
|
520
|
-
return this.toCallWithExact(clazz,
|
|
521
|
-
case
|
|
522
|
-
return this.toCallWithExact(clazz,
|
|
523
|
-
case
|
|
524
|
-
return this.toCallWithExact(clazz,
|
|
525
|
-
case
|
|
526
|
-
return this.toCallWithExact(clazz,
|
|
499
|
+
case "text":
|
|
500
|
+
return this.toCallWithExact(clazz, "getByText", body, !!options.exact);
|
|
501
|
+
case "alt":
|
|
502
|
+
return this.toCallWithExact(clazz, "getByAltText", body, !!options.exact);
|
|
503
|
+
case "placeholder":
|
|
504
|
+
return this.toCallWithExact(clazz, "getByPlaceholder", body, !!options.exact);
|
|
505
|
+
case "label":
|
|
506
|
+
return this.toCallWithExact(clazz, "getByLabel", body, !!options.exact);
|
|
507
|
+
case "title":
|
|
508
|
+
return this.toCallWithExact(clazz, "getByTitle", body, !!options.exact);
|
|
527
509
|
default:
|
|
528
|
-
throw new Error(
|
|
510
|
+
throw new Error("Unknown selector kind " + kind);
|
|
529
511
|
}
|
|
530
512
|
}
|
|
531
513
|
chainLocators(locators) {
|
|
532
|
-
return locators.join(
|
|
514
|
+
return locators.join(".");
|
|
533
515
|
}
|
|
534
516
|
regexToString(body) {
|
|
535
|
-
const suffix = body.flags.includes(
|
|
536
|
-
return `Pattern.compile(${this.quote((0,
|
|
517
|
+
const suffix = body.flags.includes("i") ? ", Pattern.CASE_INSENSITIVE" : "";
|
|
518
|
+
return `Pattern.compile(${this.quote((0, import_stringUtils.normalizeEscapedRegexQuotes)(body.source))}${suffix})`;
|
|
537
519
|
}
|
|
538
520
|
toCallWithExact(clazz, method, body, exact) {
|
|
539
|
-
if (isRegExp(body))
|
|
540
|
-
|
|
521
|
+
if (isRegExp(body))
|
|
522
|
+
return `${method}(${this.regexToString(body)})`;
|
|
523
|
+
if (exact)
|
|
524
|
+
return `${method}(${this.quote(body)}, new ${clazz}.${(0, import_stringUtils.toTitleCase)(method)}Options().setExact(true))`;
|
|
541
525
|
return `${method}(${this.quote(body)})`;
|
|
542
526
|
}
|
|
543
527
|
toHasText(body) {
|
|
544
|
-
if (isRegExp(body))
|
|
528
|
+
if (isRegExp(body))
|
|
529
|
+
return this.regexToString(body);
|
|
545
530
|
return this.quote(body);
|
|
546
531
|
}
|
|
547
532
|
toTestIdValue(value) {
|
|
548
|
-
if (isRegExp(value))
|
|
533
|
+
if (isRegExp(value))
|
|
534
|
+
return this.regexToString(value);
|
|
549
535
|
return this.quote(value);
|
|
550
536
|
}
|
|
551
537
|
quote(text) {
|
|
552
|
-
return (0,
|
|
538
|
+
return (0, import_stringUtils.escapeWithQuotes)(text, '"');
|
|
553
539
|
}
|
|
554
540
|
}
|
|
555
|
-
exports.JavaLocatorFactory = JavaLocatorFactory;
|
|
556
541
|
class CSharpLocatorFactory {
|
|
557
542
|
generateLocator(base, kind, body, options = {}) {
|
|
558
543
|
switch (kind) {
|
|
559
|
-
case
|
|
560
|
-
if (options.hasText !==
|
|
561
|
-
|
|
544
|
+
case "default":
|
|
545
|
+
if (options.hasText !== void 0)
|
|
546
|
+
return `Locator(${this.quote(body)}, new() { ${this.toHasText(options.hasText)} })`;
|
|
547
|
+
if (options.hasNotText !== void 0)
|
|
548
|
+
return `Locator(${this.quote(body)}, new() { ${this.toHasNotText(options.hasNotText)} })`;
|
|
562
549
|
return `Locator(${this.quote(body)})`;
|
|
563
|
-
case
|
|
550
|
+
case "frame-locator":
|
|
564
551
|
return `FrameLocator(${this.quote(body)})`;
|
|
565
|
-
case
|
|
552
|
+
case "frame":
|
|
566
553
|
return `ContentFrame`;
|
|
567
|
-
case
|
|
554
|
+
case "nth":
|
|
568
555
|
return `Nth(${body})`;
|
|
569
|
-
case
|
|
556
|
+
case "first":
|
|
570
557
|
return `First`;
|
|
571
|
-
case
|
|
558
|
+
case "last":
|
|
572
559
|
return `Last`;
|
|
573
|
-
case
|
|
574
|
-
return `Filter(new() { Visible = ${body ===
|
|
575
|
-
case
|
|
560
|
+
case "visible":
|
|
561
|
+
return `Filter(new() { Visible = ${body === "true" ? "true" : "false"} })`;
|
|
562
|
+
case "role":
|
|
576
563
|
const attrs = [];
|
|
577
564
|
if (isRegExp(options.name)) {
|
|
578
565
|
attrs.push(`NameRegex = ${this.regexToString(options.name)}`);
|
|
579
|
-
} else if (typeof options.name ===
|
|
566
|
+
} else if (typeof options.name === "string") {
|
|
580
567
|
attrs.push(`Name = ${this.quote(options.name)}`);
|
|
581
|
-
if (options.exact)
|
|
568
|
+
if (options.exact)
|
|
569
|
+
attrs.push(`Exact = true`);
|
|
582
570
|
}
|
|
583
|
-
for (const {
|
|
584
|
-
name
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
return `GetByRole(AriaRole.${(0, _stringUtils.toTitleCase)(body)}${attrString})`;
|
|
589
|
-
case 'has-text':
|
|
571
|
+
for (const { name, value } of options.attrs)
|
|
572
|
+
attrs.push(`${(0, import_stringUtils.toTitleCase)(name)} = ${typeof value === "string" ? this.quote(value) : value}`);
|
|
573
|
+
const attrString = attrs.length ? `, new() { ${attrs.join(", ")} }` : "";
|
|
574
|
+
return `GetByRole(AriaRole.${(0, import_stringUtils.toTitleCase)(body)}${attrString})`;
|
|
575
|
+
case "has-text":
|
|
590
576
|
return `Filter(new() { ${this.toHasText(body)} })`;
|
|
591
|
-
case
|
|
577
|
+
case "has-not-text":
|
|
592
578
|
return `Filter(new() { ${this.toHasNotText(body)} })`;
|
|
593
|
-
case
|
|
579
|
+
case "has":
|
|
594
580
|
return `Filter(new() { Has = ${body} })`;
|
|
595
|
-
case
|
|
581
|
+
case "hasNot":
|
|
596
582
|
return `Filter(new() { HasNot = ${body} })`;
|
|
597
|
-
case
|
|
583
|
+
case "and":
|
|
598
584
|
return `And(${body})`;
|
|
599
|
-
case
|
|
585
|
+
case "or":
|
|
600
586
|
return `Or(${body})`;
|
|
601
|
-
case
|
|
587
|
+
case "chain":
|
|
602
588
|
return `Locator(${body})`;
|
|
603
|
-
case
|
|
589
|
+
case "test-id":
|
|
604
590
|
return `GetByTestId(${this.toTestIdValue(body)})`;
|
|
605
|
-
case
|
|
606
|
-
return this.toCallWithExact(
|
|
607
|
-
case
|
|
608
|
-
return this.toCallWithExact(
|
|
609
|
-
case
|
|
610
|
-
return this.toCallWithExact(
|
|
611
|
-
case
|
|
612
|
-
return this.toCallWithExact(
|
|
613
|
-
case
|
|
614
|
-
return this.toCallWithExact(
|
|
591
|
+
case "text":
|
|
592
|
+
return this.toCallWithExact("GetByText", body, !!options.exact);
|
|
593
|
+
case "alt":
|
|
594
|
+
return this.toCallWithExact("GetByAltText", body, !!options.exact);
|
|
595
|
+
case "placeholder":
|
|
596
|
+
return this.toCallWithExact("GetByPlaceholder", body, !!options.exact);
|
|
597
|
+
case "label":
|
|
598
|
+
return this.toCallWithExact("GetByLabel", body, !!options.exact);
|
|
599
|
+
case "title":
|
|
600
|
+
return this.toCallWithExact("GetByTitle", body, !!options.exact);
|
|
615
601
|
default:
|
|
616
|
-
throw new Error(
|
|
602
|
+
throw new Error("Unknown selector kind " + kind);
|
|
617
603
|
}
|
|
618
604
|
}
|
|
619
605
|
chainLocators(locators) {
|
|
620
|
-
return locators.join(
|
|
606
|
+
return locators.join(".");
|
|
621
607
|
}
|
|
622
608
|
regexToString(body) {
|
|
623
|
-
const suffix = body.flags.includes(
|
|
624
|
-
return `new Regex(${this.quote((0,
|
|
609
|
+
const suffix = body.flags.includes("i") ? ", RegexOptions.IgnoreCase" : "";
|
|
610
|
+
return `new Regex(${this.quote((0, import_stringUtils.normalizeEscapedRegexQuotes)(body.source))}${suffix})`;
|
|
625
611
|
}
|
|
626
612
|
toCallWithExact(method, body, exact) {
|
|
627
|
-
if (isRegExp(body))
|
|
628
|
-
|
|
613
|
+
if (isRegExp(body))
|
|
614
|
+
return `${method}(${this.regexToString(body)})`;
|
|
615
|
+
if (exact)
|
|
616
|
+
return `${method}(${this.quote(body)}, new() { Exact = true })`;
|
|
629
617
|
return `${method}(${this.quote(body)})`;
|
|
630
618
|
}
|
|
631
619
|
toHasText(body) {
|
|
632
|
-
if (isRegExp(body))
|
|
620
|
+
if (isRegExp(body))
|
|
621
|
+
return `HasTextRegex = ${this.regexToString(body)}`;
|
|
633
622
|
return `HasText = ${this.quote(body)}`;
|
|
634
623
|
}
|
|
635
624
|
toTestIdValue(value) {
|
|
636
|
-
if (isRegExp(value))
|
|
625
|
+
if (isRegExp(value))
|
|
626
|
+
return this.regexToString(value);
|
|
637
627
|
return this.quote(value);
|
|
638
628
|
}
|
|
639
629
|
toHasNotText(body) {
|
|
640
|
-
if (isRegExp(body))
|
|
630
|
+
if (isRegExp(body))
|
|
631
|
+
return `HasNotTextRegex = ${this.regexToString(body)}`;
|
|
641
632
|
return `HasNotText = ${this.quote(body)}`;
|
|
642
633
|
}
|
|
643
634
|
quote(text) {
|
|
644
|
-
return (0,
|
|
635
|
+
return (0, import_stringUtils.escapeWithQuotes)(text, '"');
|
|
645
636
|
}
|
|
646
637
|
}
|
|
647
|
-
exports.CSharpLocatorFactory = CSharpLocatorFactory;
|
|
648
638
|
class JsonlLocatorFactory {
|
|
649
639
|
generateLocator(base, kind, body, options = {}) {
|
|
650
640
|
return JSON.stringify({
|
|
@@ -654,12 +644,12 @@ class JsonlLocatorFactory {
|
|
|
654
644
|
});
|
|
655
645
|
}
|
|
656
646
|
chainLocators(locators) {
|
|
657
|
-
const objects = locators.map(l => JSON.parse(l));
|
|
658
|
-
for (let i = 0; i < objects.length - 1; ++i)
|
|
647
|
+
const objects = locators.map((l) => JSON.parse(l));
|
|
648
|
+
for (let i = 0; i < objects.length - 1; ++i)
|
|
649
|
+
objects[i].next = objects[i + 1];
|
|
659
650
|
return JSON.stringify(objects[0]);
|
|
660
651
|
}
|
|
661
652
|
}
|
|
662
|
-
exports.JsonlLocatorFactory = JsonlLocatorFactory;
|
|
663
653
|
const generators = {
|
|
664
654
|
javascript: JavaScriptLocatorFactory,
|
|
665
655
|
python: PythonLocatorFactory,
|
|
@@ -669,4 +659,15 @@ const generators = {
|
|
|
669
659
|
};
|
|
670
660
|
function isRegExp(obj) {
|
|
671
661
|
return obj instanceof RegExp;
|
|
672
|
-
}
|
|
662
|
+
}
|
|
663
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
664
|
+
0 && (module.exports = {
|
|
665
|
+
CSharpLocatorFactory,
|
|
666
|
+
JavaLocatorFactory,
|
|
667
|
+
JavaScriptLocatorFactory,
|
|
668
|
+
JsonlLocatorFactory,
|
|
669
|
+
PythonLocatorFactory,
|
|
670
|
+
asLocator,
|
|
671
|
+
asLocatorDescription,
|
|
672
|
+
asLocators
|
|
673
|
+
});
|