Code Monkey home page Code Monkey logo

appium-interceptor-plugin's Introduction


ATD


Appium Parallel Execution for Android and iOS on Real Devices

Open Source Love Join the chat at https://gitter.im/saikrishna321/AppiumTestDistribution CircleCI GitHub stars PRs Welcome GitHub forks

CircleCI

Thanks for support

ATD ATD

ATD

Add the below dependencies in your pom.xml (Master)

Please make sure you have installed Appium v2.0 and appium-device-farm plugin

<dependency>
    <groupId>com.github.AppiumTestDistribution</groupId>
    <artifactId>AppiumTestDistribution</artifactId>
    <version>latest_commit</version>
</dependency>
<repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
</repositories>
 <dependency>
   <groupId>com.github.saikrishna321</groupId>
   <artifactId>AppiumTestDistribution</artifactId>
   <version>13.1.0</version>
 </dependency>

ReportPortal

Add LISTENERS=com.epam.reportportal.testng.ReportPortalTestNGListener to config.properties to send data to report portal.

Sample Tests

Clone the project (https://github.com/saikrishna321/PageObjectPatternAppium) If your application is cross-platform and you end up building a PageObjectPattern Framework. Then you can also run those tests across Android and iOS devices connected to the same Mac OSX Host.

(e.g. If you have 3 Android and 3 iOS devices connected to the same machine, you will be able to execute these tests parallel on both platforms)

Video log Prerequisites

  • Install ffmpeg. OSX
    • $ brew update
    • $ brew install ffmpeg
    • `
  • Install ffmpeg. windows

Runner

Videos will be logged for failure tests
VIDEO_LOGS="true" mvn clean -Dtest=Runner test 

Credits

Thanks to

Parallel Run

ScreenShot

FAQ

Q. Can I automate application which I already have installed/downloaded from App store?

A. With XCUITest framework, that is available from iOS version 9.3, it's possible to execute Native (WebViews content would not be reachable) application using its bundle id.

In order to get information about bundle id of pre-installed application:

  • connect device with application installed;
  • run ideviceinstaller -l or ideviceinstaller -l -u {udid of the device} in case more than one device connected to the host;
  • in the list - find name of the application followed by its bundle id.

After that, instead of app capability bundleId should be used with application's bundle id as a value. Since Appium still needs WDA to be built and deployed on the real device - valid certificate and provisioning profile will be needed. More information could be found here

In case the tests need to interact with WebViews and/or iOS version has no support of XCUITest - Appium would need instruments application which is in debug mode. It will not work with any application which is not in debug mode. Read more about it here

Q. Does this framework support running multiple iOS simulators?

A. Yes, currently Appium does support multiple simulators with latest 1.6.6.beta with Xcode9-beta.

Q. Unable to instrument application or instruments crashed on start up?

A. Below are few possible causes

  • (app/ipa) is not on debug mode.
  • (app) targeted to simulator will not work with real device and vice versa
  • Check device's developer option in settings.

Q. Unable to install application during automation?

A. A quick solution would be to try to install the application using "ideviceinstaller -i ipa_name". If that does not work, check app is built with a valid provisioning profile.

Q. Can I run tests on iOS app for which I have source code(e.g:"Wordpress") on real devices?

A. Yes, with a valid provisioning profile, this app can be installed on your device. (Note: The application must be signed with a valid developer certificate and your device should be added to the provisioning profile)

Organizations ๐Ÿ’™

ThoughtWorks CeX Travelstart
ThoughtWorks Cex Travelstart
Jio India M800 Reward Gateway
Jio M800 Reward
dahmakan

License

AppiumTestDistribution is released under License: MIT

Copyright (c) 2023 AppiumTestDistribution

appium-interceptor-plugin's People

Contributors

anilpatidar avatar anuj-agrawal-groww avatar bardius avatar lovesoni avatar pr4bh4sh avatar saikrishna321 avatar srinivasantarget avatar sudharsan-selvaraj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

appium-interceptor-plugin's Issues

`java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.`

Describe the Issue
I have a Hybrid Application developed using CapacitorJS.
I am using Appium with WebDriverIO.
I am mocking the REST API in test by following the guide in this repo, however, when the request is sent by the app this exception arises in logcat

java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
                                                                                                    javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
                                                                                                    	at com.android.org.conscrypt.SSLUtils.toSSLHandshakeException(SSLUtils.java:356)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngine.convertException(ConscryptEngine.java:1134)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngine.readPlaintextData(ConscryptEngine.java:1089)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngine.unwrap(ConscryptEngine.java:876)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngine.unwrap(ConscryptEngine.java:747)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngine.unwrap(ConscryptEngine.java:712)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.processDataFromSocket(ConscryptEngineSocket.java:896)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.-$$Nest$mprocessDataFromSocket(Unknown Source:0)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngineSocket.doHandshake(ConscryptEngineSocket.java:236)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngineSocket.startHandshake(ConscryptEngineSocket.java:218)
                                                                                                    	at com.android.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:196)
                                                                                                    	at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:153)
                                                                                                    	at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:116)
                                                                                                    	at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:186)
                                                                                                    	at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128)
                                                                                                    	at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
                                                                                                    	at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289)
                                                                                                    	at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232)
                                                                                                    	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)
                                                                                                    	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
                                                                                                    	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:262)
                                                                                                    	at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:219)
                                                                                                    	at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:30)
                                                                                                    	at com.getcapacitor.plugin.util.CapacitorHttpUrlConnection.writeRequestBody(CapacitorHttpUrlConnection.java:239)
                                                                                                    	at com.getcapacitor.plugin.util.CapacitorHttpUrlConnection.setRequestBody(CapacitorHttpUrlConnection.java:210)
                                                                                                    	at com.getcapacitor.plugin.util.HttpRequestHandler.request(HttpRequestHandler.java:414)
                                                                                                    	at com.getcapacitor.plugin.CapacitorHttp$1.run(CapacitorHttp.java:66)
                                                                                                    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
                                                                                                    	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
                                                                                                    Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
                                                                                                    	at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:656)
                                                                                                    	at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:505)
                                                                                                    	at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:425)
                                                                                                    	at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:353)
                                                                                                    	at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)
                                                                                                    	at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:90)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngineSocket$2.checkServerTrusted(ConscryptEngineSocket.java:163)
2024-03-25 19:13:15.169  6592-6756  Capacitor/Plugin                  E  	at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:260)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngine.verifyCertificateChain(ConscryptEngine.java:1638)
                                                                                                    	at com.android.org.conscrypt.NativeCrypto.ENGINE_SSL_read_direct(Native Method)
                                                                                                    	at com.android.org.conscrypt.NativeSsl.readDirectByteBuffer(NativeSsl.java:569)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngine.readPlaintextDataDirect(ConscryptEngine.java:1095)
                                                                                                    	at com.android.org.conscrypt.ConscryptEngine.readPlaintextData(ConscryptEngine.java:1079)

I have also replaced the implementation of fetch and XMLHttpRequest with native implementation using Capacitor HTTP Plugin, still got no success.

How to reproduce ?

  1. Create a Capacitor App.
  2. Replace the fetch and XMLHttpRequest with native implementation using Capacitor HTTP Plugin.
  3. Write a fetch request from JS Code.
  4. follow the guide on this repo to setup appium-interceptor-plugin.
  5. Test the application.

Device Information
OS: Android
Version: API 34 (Android 14)
Device: Pixel 7 Pro

Proxy does not work on the device

2024-05-15T10:03:44.498Z ERROR webdriver: RequestError: connect ECONNREFUSED 127.0.0.1:54578
[0-0] at ClientRequest. (file:///Users/purvikeny/Desktop/Tesco%20Mobile/TescoAppAutomationCode/mobileapp-tests/node_modules/got/dist/source/core/index.js:790:107)
[0-0] at Object.onceWrapper (node:events:632:26)
[0-0] at ClientRequest.emit (node:events:529:35)
[0-0] at ClientRequest.emit (node:domain:489:12)
[0-0] at Socket.socketErrorListener (node:_http_client:501:9)
[0-0] at Socket.emit (node:events:517:28)
[0-0] at Socket.emit (node:domain:489:12)
[0-0] at emitErrorNT (node:internal/streams/destroy:151:8)
[0-0] at emitErrorCloseNT (node:internal/streams/destroy:116:3)
[0-0] at processTicksAndRejections (node:internal/process/task_queues:82:21)
[0-0] at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)
[0-0] 2024-05-15T10:03:44.499Z ERROR @wdio/runner: Error: Failed to create session.
[0-0] Unable to connect to "http://127.0.0.1:54578/", make sure browser driver is running on that address.
[0-0] It seems like the service failed to start or is rejecting any connections.
[0-0] at startWebDriverSession (file:///Users/purvikeny/Desktop/Tesco%20Mobile/TescoAppAutomationCode/mobileapp-tests/node_modules/webdriver/build/utils.js:69:15)
[0-0] at processTicksAndRejections (node:internal/process/task_queues:95:5)
[0-0] at async Function.newSession (file:///Users/purvikeny/Desktop/Tesco%20Mobile/TescoAppAutomationCode/mobileapp-tests/node_modules/webdriver/build/index.js:20:45)
[0-0] at async remote (file:///Users/purvikeny/Desktop/Tesco%20Mobile/TescoAppAutomationCode/mobileapp-tests/node_modules/webdriverio/build/index.js:46:22)
[0-0] at async Runner._startSession (file:///Users/purvikeny/Desktop/Tesco%20Mobile/TescoAppAutomationCode/mobileapp-tests/node_modules/@wdio/runner/build/index.js:241:29)
[0-0] at async Runner._initSession (file:///Users/purvikeny/Desktop/Tesco%20Mobile/TescoAppAutomationCode/mobileapp-tests/node_modules/@wdio/runner/build/index.js:207:25)
[0-0] at async Runner.run (file:///Users/purvikeny/Desktop/Tesco%20Mobile/TescoAppAutomationCode/mobileapp-tests/node_modules/@wdio/runner/build/index.js:88:19)
[0-0] 2024-05-15T10:03:44.501Z DEBUG @wdio/utils:shim: Finished to run "after" hook in 0ms
2024-05-15T10:03:44.631Z DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 1
[0-0] FAILED in Android - file:///Users/purvikeny/Desktop/Tesco%20Mobile/TescoAppAutomationCode/mobileapp-tests/tests/paym/specs/journeys/change_password.spec.ts
2024-05-15T10:03:44.631Z INFO @wdio/cli:launcher: Run onWorkerEnd hook
2024-05-15T10:03:44.632Z DEBUG @wdio/cli:utils: Finished to run "onWorkerEnd" hook in 0ms
2024-05-15T10:03:44.632Z INFO @wdio/cli:launcher: Run onComplete hook
2024-05-15T10:03:44.632Z INFO @wdio/appium-service: Appium (pid: 21782) killed
2024-05-15T10:03:44.632Z DEBUG @wdio/cli:utils: Finished to run "onComplete" hook in 0ms

Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:02

2024-05-15T10:03:44.634Z INFO @wdio/local-runner: Shutting down spawned worker
2024-05-15T10:03:44.887Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2024-05-15T10:03:44.889Z INFO @wdio/local-runner: shutting down
purvikeny@Purvis-MacBook-Pro mobileapp-tests %

Error(Android): Invalid agrument: Did not receive an appropriate execute method parameters object. It needs to be deserializable as a plain JS object

Describe the issue
Mocking request using below code

await driver.execute("interceptor: addMock", [
      {
        config: {
          url: "https://domain/sms/sendOTP",
          method: "POST",
          responseBody: JSON.stringify({
            success: true,
            message: "OTP sent successfully",
          }),
        },
      },
    ]);

results in this error on Appium server logs
invalid argument: Did not receive an appropriate execute method parameters object. It needs to be deserializable as a plain JS object

This also happens if we pass an empty object or the example code in the commands sections

 const authorizationMock = await driver.execute("interceptor: addMock", [{
    config: {
        url: "**/reqres.in/**",
        headers: {
            "Authorization" : "Bearer bearertoken"
        }
    }
 }]);

Device Information
OS: Android
Version: API 34 (Android 14)
Device: Pixel 7 Pro

Error installing Appium-interceptor-plugin through commandline

Command used to install plugin: appium plugin install --source=npm appium-interceptor-plugin
Machine Apple Macbook(Intel i9)
Output
Error: npm command 'info appium-interceptor-plugin peerDependencies dependencies --json' failed with code 1.

STDOUT:
{
"error": {
"code": "E404",
"summary": "Not Found - GET https://registry.npmjs.org/appium-interceptor-plugin - Not found",
"detail": "\n 'appium-interceptor-plugin@*' is not in this registry.\n\nNote that you can also install from a\ntarball, folder, http url, or git url."
}
}

STDERR:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/appium-interceptor-plugin - Not found
npm ERR! 404
npm ERR! 404 'appium-interceptor-plugin@*' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in: /Users/{username}/.npm/_logs/2024-01-08T09_54_15_622Z-debug-0.log

It looks like plugin is not available on global registry

Error: Android 14 CA certifcate installed testing connection fails

Describe the issue
After manually copying and installing CA certificate on Android Emulator. And running this command appium plugin run appium-interceptor test-connection.
I am getting
image
but on the emulator I am getting this

How do we solve this ?

Device Information
OS: Android
Version: API 34 (Android 14)
Device: Pixel 7 Pro

interceptor: startListening command not supported

I am facing "interceptor: startListening" command not supported
My appium version is: 2.0.1
Appium-interceptor plugin version: 1.0.0-beta.8
Java 11
capabilities.setCapability("appium:intercept ", "true");

Logs:

WARN Appium   - Plugin "appium-interceptor" (package `appium-interceptor`) may be incompatible with the current version of Appium (v2.0.1) due to its peer dependency on older Appium v^2.4.1. Please ask the developer of `appium-interceptor` to update the peer dependency on Appium to v2.0.1.
[Appium] Attempting to load plugin appium-interceptor...
[Appium] Welcome to Appium v2.0.1 (REV bab86d5de571015b63fd8fc30b47bbe072a1290e)
[Appium] Non-default server args:
[Appium] { address: '127.0.0.1',
[Appium]   allowInsecure: [ 'chromedriver_autodownload' ],
[Appium]   basePath: '/wd/hub/',
[Appium]   loglevel: 'info',
[Appium]   port: 48884,
[Appium]   relaxedSecurityEnabled: true,
[Appium]   usePlugins: [ 'appium-interceptor' ] }
[Appium] Attempting to load driver uiautomator2...
[Appium] Attempting to load driver xcuitest...
[Appium] Appium REST http interface listener started on http://127.0.0.1:48884/wd/hub
[Appium] Available drivers:
[Appium]   - [email protected] (automationName 'UiAutomator2')
[Appium]   - [email protected] (automationName 'XCUITest')
[Appium] Available plugins:
[Appium]   - [email protected]
[Appium]   - [email protected] (ACTIVE)
[HTTP] --> GET /wd/hub/status
[HTTP] {}
[HTTP] <-- GET /wd/hub/status 200 3 ms - 128
[HTTP] 


######### APPIUM SERVER DASHBOARD ############
http://127.0.0.1:48884/device-farm
############################################## 


Test suite started at : 12:25:33
Total test cases : 1
Starting android app
Test case running number is : 1 out of total number of test cases : 1
Test case running is : skipGoogleLogin, which started at : 12:25:51
###################################################################
Test results so far as below. 
Total test cases passed till now : 0
Total test cases failed till now : 0
Total test cases skipped till now : 0
###################################################################
skipGoogleLogin is skipped. It skipped at : 12:25:51
org.openqa.selenium.UnsupportedCommandException: interceptor: startListening
Build info: version: '4.9.0', revision: 'd7057100a6'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.2.1', java.version: '11.0.15.1'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [4d4e5a74-d59b-4ee4-a69c-c41a6407f495, interceptor: startListening {}]
Capabilities {appium:app: /Users/anuj/Desktop/app_aut..., appium:appPackage: com.nextbillion.groww.next, appium:appWaitForLaunch: false, appium:autoAcceptAlerts: true, appium:autoGrantPermissions: true, appium:automationName: UiAutomator2, appium:browserstack.appium_version: 2.0.0, appium:browserstack.idleTimeout: 300, appium:browserstack.local: true, appium:browserstack.networkLogs: true, appium:browserstack.networkLogsOptions: {captureContent: true}, appium:build: android/example.xml, appium:databaseEnabled: false, appium:desired: {app: /Users/anuj/Desktop/app_aut..., appWaitForLaunch: false, autoAcceptAlerts: true, autoGrantPermissions: true, automationName: UiAutomator2, browserstack.appium_version: 2.0.0, browserstack.idleTimeout: 300, browserstack.local: true, browserstack.networkLogs: true, browserstack.networkLogsOptions: {captureContent: true}, build: android/example.xml, deviceAvailabilityTimeout: , disableWindowAnimation: true, fullReset: true, ignoreHiddenApiPolicyError: true, intercept : true, noReset: false, noResetValue: false, noSign: true, platformName: ANDROID, unlockKey: 123456, unlockType: pin, useNewWDA: false}, appium:deviceApiLevel: 25, appium:deviceAvailabilityTimeout: , appium:deviceManufacturer: Google, appium:deviceModel: Android SDK built for arm64, appium:deviceName: emulator-5554, appium:deviceScreenDensity: 440, appium:deviceScreenSize: 1080x2280, appium:deviceUDID: emulator-5554, appium:disableWindowAnimation: true, appium:fullReset: true, appium:ignoreHiddenApiPolicyError: true, appium:intercept : true, appium:javascriptEnabled: true, appium:locationContextEnabled: false, appium:networkConnectionEnabled: true, appium:noReset: false, appium:noResetValue: false, appium:noSign: true, appium:pixelRatio: 2.75, appium:platformVersion: 7.1.1, appium:statBarHeight: 66, appium:takesScreenshot: true, appium:unlockKey: 123456, appium:unlockType: pin, appium:useNewWDA: false, appium:viewportRect: {height: 2214, left: 0, top: 66, width: 1080}, appium:warnings: {}, appium:webStorageEnabled: false, platformName: ANDROID}
Session ID: 4d4e5a74-d59b-4ee4-a69c-c41a6407f495
        at org.openqa.selenium.remote.codec.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:250)
        at org.openqa.selenium.remote.codec.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:122)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:181)
        at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:262)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:598)
        at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:272)
        at in.groww.automation.frontend.apps.android._GrowwAndroidApp.captureNetwork(_GrowwAndroidApp.java:116)
        at in.groww.automation.frontend.flows.VisitorFlow.setup(VisitorFlow.java:35)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
        at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
        at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:340)
        at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:294)
        at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:683)
        at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:510)
        at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:172)
        at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
        at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:804)
        at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Testcase skipped

Issue : The following script arguments are not known and will be ignored: url,statusCode | Encountered internal error running command: UnknownCommandError: Unknown mobile command "interceptor:addMock"

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'

Java Mock Example not working

`             JSONObject customObject = new JSONObject();
                customObject.put("url","/api/users?.*");
                customObject.put("responseBody","{\n" +
                        "  \"page\": 2,\n" +
                        "  \"per_page\": 6,\n" +
                        "  \"total\": 12,\n" +
                        "  \"total_pages\": 2,\n" +
                        "  \"data\": [\n" +
                        "    {\n" +
                        "      \"id\": 7,\n" +
                        "      \"email\": \"[email protected]\",\n" +
                        "      \"first_name\": \"Michael\",\n" +
                        "      \"last_name\": \"Lawson\",\n" +
                        "      \"avatar\": \"https://reqres.in/img/faces/7-image.jpg\"\n" +
                        "    }\n" +
                        "  ]\n" +
                        "}");
                JSONObject parentJson = new JSONObject();
                parentJson.put("config", customObject);
                ((JavascriptExecutor)DriverManager.getDriver()).executeScript("interceptor: addMock",new JSONObject(parentJson));
`

Using the exact same java code provided in the example, I'm getting
java.lang.IllegalArgumentException: Argument is of an illegal type: org.json.JSONObject at org.openqa.selenium.remote.internal.WebElementToJsonConverter.apply(WebElementToJsonConverter.java:83)

appium-interceptor test connection script got failed

Prerequisites:
Appium Version: 2.4.1
Npm Version: 10.2.4
Apple Macbook Intel(i9)
Steps to Reproduce
a) Install appium inspector plugin
appium plugin install --source=npm appium-interceptor
Screenshot 2024-01-08 at 18 59 30
b) Now download ca certificate from here and install it on device
Screenshot 2024-01-08 at 19 01 20
Note: Make sure certificate is trusted
c) Now test the connection with following command
appium plugin run appium-interceptor test-connection
Screenshot 2024-01-08 at 19 02 43
d) Observe that test connection script is getting failed

need help to setup proxy

i have tried to setup proxy in system

export http_proxy='myproxy:port'

but appium did not use system proxy for request it use system's network IP.

how can i solve this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.