Example 1 :
<---------Java Code------------>
Map<String, String> config = new HashMap();
config.put("url", "**/api/lobbyApi/v1/getMatches");
config.put("statusCode","500");
((JavascriptExecutor)driver).executeScript("interceptor: addMock",config);
Example 2 :
Object authorizationMock = driver.executeScript("interceptor:addMock", new Object[]{
"config", new Object[]{
"url", "**/api/lobbyApi/v1/getMatches",
"statusCode", 500
}
});
<---------Example 1 Logs------------>
[HTTP] {"script":"interceptor: addMock","args":[{"url":"/api/lobbyApi/v1/getMatches","statusCode":"500"}]}
[device-farm-/Users/anil-patidar/.appium] Updating lastCmdExecutedAt for device EQJZH6VONZA6TSWW in session fe666a72-0305-42a4-b7bd-e8d12e75e14c
[AndroidUiautomator2Driver@3e8a (fe666a72)] Calling AppiumDriver.execute() with args: ["interceptor: addMock",[{"url":"/api/lobbyApi/v1/getMatches","statusCode":"500"}],"fe666a72-0305-42a4-b7bd-e8d12e75e14c"]
[HTTP] --> POST /wd/hub/session/fe666a72-0305-42a4-b7bd-e8d12e75e14c/execute/sync
[HTTP] {"script":"interceptor: addMock","args":[{"url":"/api/lobbyApi/v1/getMatches","statusCode":"500"}]}
[device-farm-/Users/anil-patidar/.appium] Updating lastCmdExecutedAt for device EQJZH6VONZA6TSWW in session fe666a72-0305-42a4-b7bd-e8d12e75e14c
[AndroidUiautomator2Driver@3e8a (fe666a72)] Calling AppiumDriver.execute() with args: ["interceptor: addMock",[{"url":"/api/lobbyApi/v1/getMatches","statusCode":"500"}],"fe666a72-0305-42a4-b7bd-e8d12e75e14c"]
[AppiumDriver@e6c7] Clearing new command timeout pre-emptively since plugin(s) will handle this command
[AppiumDriver@e6c7] Plugins which can handle cmd 'execute': device-farm,appium-dashboard,gestures,appium-interceptor
[AppiumDriver@e6c7] Plugin appium-interceptor is now handling cmd 'execute'
[BaseDriver] The following script arguments are not known and will be ignored: url,statusCode
[AppiumDriver@e6c7] Command 'execute' was not handled by the following behaviours or plugins, even though they were registered to handle it: ["default","device-farm","appium-dashboard","gestures"]. The command was handled by these: ["appium-interceptor"].
[AppiumDriver@e6c7] Restarting new command timeout via umbrella driver since plugin did not allow default handler to execute
[AndroidUiautomator2Driver@3e8a (fe666a72)] Encountered internal error running command: BadParametersError: The following required parameter is missing: ["config"]
[AndroidUiautomator2Driver@3e8a (fe666a72)] Known required parameters are: ["config"]
[AndroidUiautomator2Driver@3e8a (fe666a72)] You have provided none
[AndroidUiautomator2Driver@3e8a (fe666a72)] at checkParams (/Users/anil-patidar/node_modules/@appium/base-driver/lib/protocol/protocol.js:159:9)
[AndroidUiautomator2Driver@3e8a (fe666a72)] at validateExecuteMethodParams (/Users/anil-patidar/node_modules/@appium/base-driver/lib/protocol/protocol.js:246:5)
[AndroidUiautomator2Driver@3e8a (fe666a72)] at AppiumInterceptorPlugin.executeMethod (/Users/anil-patidar/node_modules/@appium/base-plugin/lib/plugin.js:79:45)
[AndroidUiautomator2Driver@3e8a (fe666a72)] at AppiumInterceptorPlugin. (/Users/anil-patidar/.appium/node_modules/appium-interceptor/src/plugin.ts:165:23)
[AndroidUiautomator2Driver@3e8a (fe666a72)] at Generator.next ()
[AndroidUiautomator2Driver@3e8a (fe666a72)] at /Users/anil-patidar/.appium/node_modules/appium-interceptor/lib/plugin.js:8:71
[AndroidUiautomator2Driver@3e8a (fe666a72)] at new Promise ()
[AndroidUiautomator2Driver@3e8a (fe666a72)] at __awaiter (/Users/anil-patidar/.appium/node_modules/appium-interceptor/lib/plugin.js:4:12)
[AndroidUiautomator2Driver@3e8a (fe666a72)] at AppiumInterceptorPlugin.execute (/Users/anil-patidar/.appium/node_modules/appium-interceptor/lib/plugin.js:142:16)
[AndroidUiautomator2Driver@3e8a (fe666a72)] at /Users/anil-patidar/.nvm/versions/node/v16.15.1/lib/node_modules/appium/lib/appium.js:1175:35
[AndroidUiautomator2Driver@3e8a (fe666a72)] at AppiumDriver.executeWrappedCommand (/Users/anil-patidar/.nvm/versions/node/v16.15.1/lib/node_modules/appium/lib/appium.js:1215:22)
[AndroidUiautomator2Driver@3e8a (fe666a72)] at AppiumDriver.executeCommand (/Users/anil-patidar/.nvm/versions/node/v16.15.1/lib/node_modules/appium/lib/appium.js:1121:28)
[AndroidUiautomator2Driver@3e8a (fe666a72)] at runMicrotasks ()
[AndroidUiautomator2Driver@3e8a (fe666a72)] at processTicksAndRejections (node:internal/process/task_queues:96:5)
[AndroidUiautomator2Driver@3e8a (fe666a72)] at asyncHandler (/Users/anil-patidar/.nvm/versions/node/v16.15.1/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/protocol.js:393:19)
[W3C] Bad parameters: BadParametersError: The following required parameter is missing: ["config"]
[W3C] Known required parameters are: ["config"]
[W3C] You have provided none
[HTTP] <-- POST /wd/hub/session/fe666a72-0305-42a4-b7bd-e8d12e75e14c/execute/sync 400 214 ms - 1839
[HTTP]
[device-farm-/Users/anil-patidar/.appium] Found 1 device candidates to be released
[device-farm-/Users/anil-patidar/.appium] Cleaning pending sessions...
[device-farm-/Users/anil-patidar/.appium] No pending sessions to clean
[device-farm-/Users/anil-patidar/.appium] Found 1 device candidates to be released
[device-farm-/Users/anil-patidar/.appium] Cleaning pending sessions...
[device-farm-/Users/anil-patidar/.appium] No pending sessions to clean
HTTPS_CLIENT_ERROR
[Error: 4388980096:error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1546:SSL alert number 46
] {
library: 'SSL routines',
function: 'ssl3_read_bytes',
reason: 'sslv3 alert certificate unknown',
code: 'ERR_SSL_SSLV3_ALERT_CERTIFICATE_UNKNOWN'
}
<---------Example 2 Logs------------>
creating SNI context for conff.dc.oppomobile.com
[HTTP] --> POST /wd/hub/session/291f75ec-9509-4e27-9b0f-7649e84804b9/execute/sync
[HTTP] {"script":"interceptor:addMock","args":["config",["url","/api/lobbyApi/v1/getMatches","statusCode",500]]}
[device-farm-/Users/anil-patidar/.appium] Updating lastCmdExecutedAt for device EQJZH6VONZA6TSWW in session 291f75ec-9509-4e27-9b0f-7649e84804b9
[AndroidUiautomator2Driver@a6fb (291f75ec)] Calling AppiumDriver.execute() with args: ["interceptor:addMock",["config",["url","/api/lobbyApi/v1/getMatches","statusCode",500]],"291f75ec-9509-4e27-9b0f-7649e84804b9"]
[AppiumDriver@f5c9] Clearing new command timeout pre-emptively since plugin(s) will handle this command
[AppiumDriver@f5c9] Plugins which can handle cmd 'execute': device-farm,appium-dashboard,gestures,appium-interceptor
[AppiumDriver@f5c9] Plugin appium-interceptor is now handling cmd 'execute'
[Plugin [appium-interceptor]] Plugin did not know how to handle method 'interceptor:addMock'. Passing control to next
[AppiumDriver@f5c9] Plugin gestures is now handling cmd 'execute'
[Plugin [gestures]] Plugin did not know how to handle method 'interceptor:addMock'. Passing control to next
[AppiumDriver@f5c9] Plugin appium-dashboard is now handling cmd 'execute'
[AppiumDriver@f5c9] Plugin device-farm is now handling cmd 'execute'
[AppiumDriver@f5c9] Executing default handling behavior for command 'execute'
[device-farm-/Users/anil-patidar/.appium] Updating lastCmdExecutedAt for device EQJZH6VONZA6TSWW in session 291f75ec-9509-4e27-9b0f-7649e84804b9
[AndroidUiautomator2Driver@a6fb (291f75ec)] Encountered internal error running command: UnknownCommandError: Unknown mobile command "interceptor:addMock". Only shell, execEmuConsoleCommand, dragGesture, flingGesture, doubleClickGesture, clickGesture, longClickGesture, pinchCloseGesture, pinchOpenGesture, swipeGesture, scrollGesture, scrollBackTo, scroll, viewportScreenshot, viewportRect, deepLink, startLogsBroadcast, stopLogsBroadcast, deviceidle, acceptAlert, dismissAlert, batteryInfo, deviceInfo, getDeviceTime, changePermissions, getPermissions, performEditorAction, startScreenStreaming, stopScreenStreaming, getNotifications, openNotifications, listSms, type, replaceElementValue, pushFile, pullFile, pullFolder, deleteFile, isAppInstalled, queryAppState, activateApp, removeApp, terminateApp, installApp, clearApp, backgroundApp, getCurrentActivity, getCurrentPackage, startActivity, startService, stopService, broadcast, getContexts, getAppStrings, installMultipleApks, lock, unlock, isLocked, refreshGpsCache, startMediaProjectionRecording, isMediaProjectionRecordingRunning, stopMediaProjectionRecording, getConnectivity, setConnectivity, toggleGps, isGpsEnabled, hideKeyboard, isKeyboardShown, pressKey, getDisplayDensity, getSystemBars, fingerprint, sendSms, gsmCall, gsmSignal, gsmVoice, powerAc, powerCapacity, networkSpeed, sensorSet, getPerformanceData, getPerformanceDataTypes, statusBar, screenshots, scheduleAction, getActionHistory, unscheduleAction, getUiMode, setUiMode, sendTrimMemory commands are supported.
[AndroidUiautomator2Driver@a6fb (291f75ec)] at AndroidUiautomator2Driver.executeMobile (/Users/anil-patidar/.appium/node_modules/appium-uiautomator2-driver/lib/commands/execute.js:56:11)
[AndroidUiautomator2Driver@a6fb (291f75ec)] at AndroidUiautomator2Driver.execute (/Users/anil-patidar/.appium/node_modules/appium-uiautomator2-driver/lib/commands/execute.js:27:23)
[AndroidUiautomator2Driver@a6fb (291f75ec)] at commandExecutor (/Users/anil-patidar/node_modules/@appium/base-driver/lib/basedriver/driver.ts:106:18)
[AndroidUiautomator2Driver@a6fb (291f75ec)] at /Users/anil-patidar/node_modules/async-lock/lib/index.js:171:12
[AndroidUiautomator2Driver@a6fb (291f75ec)] at AsyncLock._promiseTry (/Users/anil-patidar/node_modules/async-lock/lib/index.js:306:31)
[AndroidUiautomator2Driver@a6fb (291f75ec)] at exec (/Users/anil-patidar/node_modules/async-lock/lib/index.js:170:9)
[AndroidUiautomator2Driver@a6fb (291f75ec)] at AsyncLock.acquire (/Users/anil-patidar/node_modules/async-lock/lib/index.js:189:3)
[AndroidUiautomator2Driver@a6fb (291f75ec)] at AndroidUiautomator2Driver.executeCommand (/Users/anil-patidar/node_modules/@appium/base-driver/lib/basedriver/driver.ts:122:39)
[AndroidUiautomator2Driver@a6fb (291f75ec)] at runMicrotasks ()
[AndroidUiautomator2Driver@a6fb (291f75ec)] at processTicksAndRejections (node:internal/process/task_queues:96:5)
[AndroidUiautomator2Driver@a6fb (291f75ec)] at defaultBehavior (/Users/anil-patidar/.nvm/versions/node/v16.15.1/lib/node_modules/appium/lib/appium.js:1109:14)
[HTTP] <-- POST /wd/hub/session/291f75ec-9509-4e27-9b0f-7649e84804b9/execute/sync 404 144 ms - 4048
[HTTP]
HTTPS_CLIENT_ERROR
[Error: 4411344256:error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1546:SSL alert number 46
] {
library: 'SSL routines',
function: 'ssl3_read_bytes',
reason: 'sslv3 alert certificate unknown',
code: 'ERR_SSL_SSLV3_ALERT_CERTIFICATE_UNKNOWN'