AppiumTestDistribution / appium-interceptor-plugin

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

Certificate unknown and no api requests returned #43

Open herby-naidz opened 2 months ago

herby-naidz commented 2 months ago

Hi

I have installed the certificate (https://github.com/AppiumTestDistribution/appium-interceptor-plugin/blob/master/certificate/certs/ca.pem) on my Android emulator (Platform 14). When I run the connection test the site does not load on my emulator and I get an error in the terminal:

Screenshot 2024-08-30 145847

When I try to use the plugin in my Appium/WebdriverIO project I don't see any errors, but I also am not able to intercept any API calls. Every now and then I do see a few calls to something Google related but nothing to our backend APIs.

Would appreciate it if you could assist.

sudharsan-selvaraj commented 2 months ago

@herby-naidz Have you followed the steps outlined in https://github.com/AppiumTestDistribution/appium-interceptor-plugin/blob/master/docs/certificate-installation.md?

After installing the certificate, can run the below command and send me the screenshot of your mobile screen.

appium plugin run appium-interceptor test-connection
herby-naidz commented 2 months ago

Hi @sudharsan-selvaraj

I have followed the steps for platform 14. This is what I see on the emulator when I test the connection with the given command:

Screenshot 2024-09-05 164520

sudharsan-selvaraj commented 2 months ago

Can you confirm if the certificate is installed properly on the device? If yes, can you check with a different emulator to see if its not an issue with the emulator that you are using.

herby-naidz commented 2 months ago

Hi @sudharsan-selvaraj

I have created a new emulator also on Platform 14. This time I used a default android system image instead of a Google APIs image. I don't know if that made the difference, but at least the connection test seems to be working (although the terminal still has the ERR_SSL_SSLV3_ALERT_CERTIFICATE_UNKNOWN error).

This is what the connection test produces on the new device:

Screenshot 2024-09-11 133422

However, running the appium/wdio tests still produced no output when trying to intercept the api calls.

At the time I was attempting to mock a few calls. I have changed the code to just the following:

await driver.execute("interceptor: startListening");

and then later in the code I have:

const apiRequests = await driver.execute("interceptor: stopListening"); console.log("REQUESTS", apiRequests);

I have removed 'appium:intercept': true, from the capabilities.

Now I get an error when I run the tests, namely:

An unknown server-side error occurred while processing the command. Original error: Proxy is not active for current session

These are the options passed in when the appium server is started:

--base-path / --address localhost --port 4723 --use-plugins appium-interceptor

I am not sure if something is missing in the above.

sudharsan-selvaraj commented 2 months ago

Is the behaviour same even if you pass appium:intercept: true? Can you also make sure the App you are testing have trusted to user certificates by following https://stackoverflow.com/questions/56295458/how-to-trust-a-user-added-certificate-in-android

herby-naidz commented 2 months ago

Hi @sudharsan-selvaraj

If I pass appium:intercept: true there are no errors, but there are also no requests being logged.

Unfortunately the app is not mine. I only have the apk. Perhaps the app is the issue. I'll see how far I get.

Thanks