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