Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to reflect response in android app using appium and Java #17

Open
ashuaviator1987 opened this issue Feb 14, 2023 · 1 comment
Open

Comments

@ashuaviator1987
Copy link

ashuaviator1987 commented Feb 14, 2023

I am using below configuration.

  1. Installed MITM certificate on my emulator.
  2. Installed MITM proxy, websocket and other related dependecy as mentioned in appiumPro article

Part of code dealing with proxy is as per below
`
List messages = new ArrayList<>();

    // remember to set local OS proxy settings in the Network Preferences
    proxy = new MitmproxyJava("C:\\Python311\\Scripts\\mitmdump.exe", (InterceptedMessage m) -> {
        if(

                m.getRequest().getUrl().toString().toLowerCase().startsWith(apiURL.toLowerCase()) &&
                m.getRequest().getMethod().equalsIgnoreCase("post")&&
                getJsonObject(new String(m.getRequest().getBody())).hasNonNull("operationName")&&
                getJsonObject(new String(m.getRequest().getBody())).get("operationName").asText().equalsIgnoreCase("getPharamcyTATInfo")
        )
        {

                JsonNode responseBodyJson = getJsonObject(new String(m.getResponse().getBody()));
                String modifiedResp = updateValuesInJson(responseBodyJson.toString(),
                        "data.getSkuInfo.tatInfo.tatResponse.inventoryExist",false,
                        "data.getSkuInfo.tatInfo.tatResponse.items[0].exist",false);
                m.getResponse().setBody(modifiedResp.getBytes(StandardCharsets.UTF_8));
                m.getResponse().getHeaders().add(new String[]{"My Test Resp Header","Header Value"});
                messages.add(m);
        }
        return m;
    });
    proxy.start();

    login(initializeDriver(testMethod),credentialManager);

`

now I have printed the intercepted message and modified response. but the app is still receiving the unmodified request.
when I do below
`
messages.forEach(
x->{
LOGGER.info("########Request Operation : "+x.toString() +getJsonObject(new String(x.getRequest().getBody())).get("operationName"));
LOGGER.info("########### Response Body :" +new String(x.getResponse().getBody()));
}

    );`

i see the proper response (modified one), this response never made it app, it is still showing the normal behaviour.

P.S. the app is Android native app
Please advice

@ashuaviator1987
Copy link
Author

@jlipps can we do a paid support for this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant