AppiumTestDistribution / appium-interceptor-plugin

Appium 2.0 plugin to mock api calls for android apps
27 stars 11 forks source link

interceptor: startListening command not supported #22

Closed anuj-agrawal-groww closed 6 months ago

anuj-agrawal-groww commented 7 months ago

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]   - uiautomator2@2.45.0 (automationName 'UiAutomator2')
[Appium]   - xcuitest@6.1.0 (automationName 'XCUITest')
[Appium] Available plugins:
[Appium]   - device-farm@8.4.7-rc.8
[Appium]   - appium-interceptor@1.0.0-beta.8 (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
sudharsan-selvaraj commented 7 months ago

i couldn't reproduce the issue from my side. Could you share me the entire complete server logs with the error message? Also attach the code you are using in the client side.

anuj-agrawal-groww commented 7 months ago

appium.log

sudharsan-selvaraj commented 7 months ago

In the appium log you attached i don't see any webdriver call made to execute script endpoint. Could you add the full logs with the error throw at executeScript command.

SubbuLomada commented 6 months ago

Hi @sudharsan-selvaraj I am also facing the same issue…. In appium logs there is calls happening related to the interceptor.

sudharsan-selvaraj commented 6 months ago

@SubbuLomada Are you calling the command using javascript executer as below

((JavascriptExecutor) driver).executeScript("interceptor: startListening");
sudharsan-selvaraj commented 6 months ago

@anuj-agrawal-groww Looks like you are using driver.execute() method instead of ((JavascriptExecutor) driver).executeScript();. I have updated the docs with a note on how to use the plugin with java client. Let me know if you still face the issue after using JavascriptExecutor.

anuj-agrawal-groww commented 6 months ago

hey @sudharsan-selvaraj, thanks for the update. I'll try it out and let you know.

SubbuLomada commented 6 months ago

Hi @sudharsan-selvaraj with JavaScript it is working fine thank you…

anuj-agrawal-groww commented 6 months ago

Hi @sudharsan-selvaraj, i tried to use the other commands using java client, but again I'm getting command not supported exception, I'm attaching the multiple approaches that i used:

String cmd="\"interceptor: startListening\", [{\n" +
                "    config: {\n" +
                "      \"include\" : {\n" +
                "        url \"**/groww.in/**\",\n" +
                "      }\n" +
                "    }\n" +
                " }]";
((JavascriptExecutor) driver).executeScript(cmd);
 String script = "interceptor: startListening([{config: {include: {url: '**/reqres.in/**'}}}]);";
        ((JavascriptExecutor) driver).executeScript(script);   
((JavascriptExecutor) driver).executeScript(
            "interceptor: startListening", 
            new Object[] { 
                new Object[] {
                    "config",
                    new Object() {
                        String include = "url **/reqres.in/**";
                    }
                }
            }
        );
BartVanRaemdonck commented 3 months ago

I'm also getting command not supported exception. Is there a fix for this?

org.openqa.selenium.UnsupportedCommandException: {"value":{"error":"unknown method","message":"Method is not implemented","stacktrace":"NotImplementedError: Method is not implemented\n at AndroidUiautomator2Driver.execute ...

I use Appiumdriver:

private static AppiumDriver driver; with

private static void setCapabilities() throws MalformedURLException {
    UiAutomator2Options options = new UiAutomator2Options();
    options.setDeviceName("OnePlus 9");
    options.setAutomationName("UIAutomator2");
    options.setPlatformName("Android");
    options.setApp(System.getProperty("user.dir") + "/demo-release - 2022-03-21T150915.559.apk");
    options.setPlatformVersion("14");
    options.setCapability("appium:intercept",true);
    driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), options);
}

I execute:

((JavascriptExecutor) driver).executeScript("interceptor:startListening");

saikrishna321 commented 3 months ago

@anuj-agrawal-groww @BartVanRaemdonck can you please share full server logs as gist

BartVanRaemdonck commented 3 months ago

My logs:

org.openqa.selenium.UnsupportedCommandException: {"value":{"error":"unknown method","message":"Method is not implemented","stacktrace":"NotImplementedError: Method is not implemented\n at AndroidUiautomator2Driver.execute (/Users/bvanraemdonck/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/execute.js:121:11)\n at commandExecutor (/opt/homebrew/Cellar/appium/2.5.4/libexec/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/driver.ts:106:18)\n at /opt/homebrew/Cellar/appium/2.5.4/libexec/lib/node_modules/appium/node_modules/async-lock/lib/index.js:171:12\n at AsyncLock._promiseTry (/opt/homebrew/Cellar/appium/2.5.4/libexec/lib/node_modules/appium/node_modules/async-lock/lib/index.js:306:31)\n at exec (/opt/homebrew/Cellar/appium/2.5.4/libexec/lib/node_modules/appium/node_modules/async-lock/lib/index.js:170:9)\n at AsyncLock.acquire (/opt/homebrew/Cellar/appium/2.5.4/libexec/lib/node_modules/appium/node_modules/async-lock/lib/index.js:189:3)\n at AndroidUiautomator2Driver.executeCommand (/opt/homebrew/Cellar/appium/2.5.4/libexec/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/driver.ts:122:39)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at defaultBehavior (/opt/homebrew/Cellar/appium/2.5.4/libexec/lib/node_modules/appium/lib/appium.js:1109:14)\n at AppiumInterceptorPlugin.executeMethod (/opt/homebrew/Cellar/appium/2.5.4/libexec/lib/node_modules/appium/node_modules/@appium/base-plugin/lib/plugin.js:73:14)"}} Command duration or timeout: 10 milliseconds Build info: version: '4.21.0', revision: '79ed462ef4' System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '14.5', java.version: '15.0.10' Driver info: io.appium.java_client.android.AndroidDriver Command: [d044b5f7-9847-4230-8c71-f3554a4ee50d, executeScript {script=interceptor:startListening, args=[]}] Capabilities {appium:app: /Users/bvanraemdonck/Docume..., appium:appPackage: be.persgroep.advertising.ba..., appium:automationName: UIAutomator2, appium:databaseEnabled: false, appium:desired: {app: /Users/bvanraemdonck/Docume..., automationName: UIAutomator2, deviceName: OnePlus 9, intercept: true, platformName: ANDROID, platformVersion: 14}, appium:deviceApiLevel: 34, appium:deviceManufacturer: OnePlus, appium:deviceModel: LE2113, appium:deviceName: 42fd9bd6, appium:deviceScreenDensity: 480, appium:deviceScreenSize: 1080x2400, appium:deviceUDID: 42fd9bd6, appium:intercept: true, appium:javascriptEnabled: true, appium:locationContextEnabled: false, appium:networkConnectionEnabled: true, appium:pixelRatio: 3, appium:platformVersion: 14, appium:statBarHeight: 103, appium:takesScreenshot: true, appium:viewportRect: {height: 2297, left: 0, top: 103, width: 1080}, appium:warnings: {}, appium:webStorageEnabled: false, platformName: ANDROID} Session ID: d044b5f7-9847-4230-8c71-f3554a4ee50d at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:221) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:170) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:571) at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:463) at FirstTestA.firstTest(FirstTestA.java:80) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

saikrishna321 commented 3 months ago

Share full server logs

BartVanRaemdonck commented 3 months ago

Is this enough? https://gist.github.com/BartVanRaemdonck/6749e612679b96ef48bd4203c8b59b7b

BartVanRaemdonck commented 3 months ago

Hi, I was just checking in if someone had time to check my logs? Maybe we could reopen this issue?

sudharsan-selvaraj commented 3 months ago

@BartVanRaemdonck The command is incorrect(missed a white space after :). The actual command is interceptor: startListening