Read api calls of app with AppiumHow do I call one constructor from another in Java?How do I read / convert an InputStream into a String in Java?REST API Best practice: How to accept list of parameter values as inputDoes anyone have benchmarks (code & results) comparing performance of Android apps written in Xamarin C# and Java?Appium driver for CapybaraIn Mobile Native App Testing: How to mock backend when using Appium?Call App From Background - Appium/AndroidAutomate Opera Mini Tests via Appium/SeleniumMobile game testing using AppiumWhat is the difference between Appium-XCUITest-Driver and appium-dotnet-driver?
How did Lefschetz do mathematics without hands?
Can someone break into a Leomund's Tiny Hut via the Ethereal Plane?
Create custom script for send mail in magento 1.9
How to answer "write something on the board"?
Adjective for 'made of pus' or 'corrupted by pus' or something of something of pus
What was the impact of Fischer vs. Spassky 1972 on the relationship between the USA and the Soviet Union?
cannot execute script while its permission is 'x'
Could human civilization live 150 years in a nuclear-powered aircraft carrier colony without resorting to mass killing/ cannibalism?
My colleague is constantly blaming me for his errors
Could a Weapon of Mass Destruction, targeting only humans, be developed?
I'm reinstalling my Linux desktop, how do I keep SSH logins working?
Why transcripts instead of degree certificates?
One folder having two different locations on Ubuntu 18.04
What does grep -v "grep" mean and do?
What's the safest way to inform a new user of their password on an invite-only website?
How do I tell the reader that my character is autistic in Fantasy?
Meaning of じゃないんじゃない?
What is the purpose of putting a capacitor on the primary side of a step-down transformer?
Why was Mal so quick to drop Bester in favour of Kaylee?
In native German words, is Q always followed by U, as in English?
What's the easiest way for a whole party to be able to communicate with a creature that doesn't know Common?
Pairwise Scatter Plots with Histograms and Correlations
Is the location of an aircraft spoiler really that vital?
Does the Pi 4 resolve the Ethernet+USB bottleneck issue of past versions?
Read api calls of app with Appium
How do I call one constructor from another in Java?How do I read / convert an InputStream into a String in Java?REST API Best practice: How to accept list of parameter values as inputDoes anyone have benchmarks (code & results) comparing performance of Android apps written in Xamarin C# and Java?Appium driver for CapybaraIn Mobile Native App Testing: How to mock backend when using Appium?Call App From Background - Appium/AndroidAutomate Opera Mini Tests via Appium/SeleniumMobile game testing using AppiumWhat is the difference between Appium-XCUITest-Driver and appium-dotnet-driver?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
we are experimenting with Appium for our mobile testing. I couldn't find how to read the API calls our app does towards our backend. Is it possible to 'listen' to the network calls of the app and for example read the JSON body that is returned from our backend?
Thanks
java api testing mobile appium
add a comment |
we are experimenting with Appium for our mobile testing. I couldn't find how to read the API calls our app does towards our backend. Is it possible to 'listen' to the network calls of the app and for example read the JSON body that is returned from our backend?
Thanks
java api testing mobile appium
add a comment |
we are experimenting with Appium for our mobile testing. I couldn't find how to read the API calls our app does towards our backend. Is it possible to 'listen' to the network calls of the app and for example read the JSON body that is returned from our backend?
Thanks
java api testing mobile appium
we are experimenting with Appium for our mobile testing. I couldn't find how to read the API calls our app does towards our backend. Is it possible to 'listen' to the network calls of the app and for example read the JSON body that is returned from our backend?
Thanks
java api testing mobile appium
java api testing mobile appium
asked May 25 '16 at 9:53
vm31vm31
4910 bronze badges
4910 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There are two possible ways of recording the network calls:
1) Set up proxy in your mobile via any of the proxy tool you use like charles, wireshark. What I mean is manually open whatever GUI tool you have and route your traffic via the tool as when you want to listen to network traffic.
2) Another way is through browsermob proxy. This would generate a HAR file of all the network calls that were made(would give the headers of the response and not JSON data).Maven Dependency is:
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-core-littleproxy</artifactId>
<version>2.1.0-beta-3</version>
</dependency>
Add this where you create your environment:
// Starting server BrowserMobProxy
server= new BrowserMobProxyServer();
server.setConnectTimeout(10, TimeUnit.SECONDS);
server.start(8897);
Proxy proxy = ClientUtil.createSeleniumProxy(server);
Set capabilities:
capabilities.setCapability(CapabilityType.PROXY, proxy);
After the driver is set up, create a HAR file
server.newHar("2.har");
In your @AfterSuite add below:
if(server.getHar()==null)
System.out.println("No Har capture");
Har har = server.getHar();
if(har==null)
System.out.println("Har is NULL");
FileOutputStream fos = new FileOutputStream(FILE_OUTPUT_HAR+"fos"+".har");
har.writeTo(fos);
HarLog log = har.getLog();
if(log==null)
System.out.println("Harlog is null");
List<HarEntry> entries = new CopyOnWriteArrayList<HarEntry>(log.getEntries());
System.out.println("entries"+entries);
for (HarEntry entry : entries)
System.out.println("entry="+entry.getRequest().getUrl());
File harFile = new File(HAR_FILE_PATH+"2"+".har");
File("/Users/yourpath/"+"2"+".har");
har.writeTo(harFile);
Thanks Tabish. Does this work in with Appium server as well? I noticed appium is not supported by BrowserMobProxy. Here is the link github.com/appium/appium/issues/4968. Do you have any suggestions?
– vm31
May 26 '16 at 18:39
I tried the apporach as well you mentioned, har file is generated without any information more than the basics. Here is the info. "log": "version": "1.2", "creator": "name": "BrowserMob Proxy", "version": "2.1.0-beta-3-littleproxy", "comment": "" , "pages": [ "id": "Second.har", "startedDateTime": "2016-05-26T21:42:46.453+02:00", "title": "Second.har", "pageTimings": "comment": "" , "comment": "" ], "entries": [], "comment": ""
– vm31
May 26 '16 at 19:48
Did you set up your phone to route its traffic via proxy port(8897 in the example)?
– Tabish Javed
May 27 '16 at 5:21
Yes Tried it that but app starts complaining that the network is being monitored. Also my app does not work on Rooted devices.
– vm31
May 28 '16 at 20:23
Any idea how can make my device listen to BrowserMobProxy server?
– vm31
Jun 1 '16 at 12:32
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37433606%2fread-api-calls-of-app-with-appium%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are two possible ways of recording the network calls:
1) Set up proxy in your mobile via any of the proxy tool you use like charles, wireshark. What I mean is manually open whatever GUI tool you have and route your traffic via the tool as when you want to listen to network traffic.
2) Another way is through browsermob proxy. This would generate a HAR file of all the network calls that were made(would give the headers of the response and not JSON data).Maven Dependency is:
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-core-littleproxy</artifactId>
<version>2.1.0-beta-3</version>
</dependency>
Add this where you create your environment:
// Starting server BrowserMobProxy
server= new BrowserMobProxyServer();
server.setConnectTimeout(10, TimeUnit.SECONDS);
server.start(8897);
Proxy proxy = ClientUtil.createSeleniumProxy(server);
Set capabilities:
capabilities.setCapability(CapabilityType.PROXY, proxy);
After the driver is set up, create a HAR file
server.newHar("2.har");
In your @AfterSuite add below:
if(server.getHar()==null)
System.out.println("No Har capture");
Har har = server.getHar();
if(har==null)
System.out.println("Har is NULL");
FileOutputStream fos = new FileOutputStream(FILE_OUTPUT_HAR+"fos"+".har");
har.writeTo(fos);
HarLog log = har.getLog();
if(log==null)
System.out.println("Harlog is null");
List<HarEntry> entries = new CopyOnWriteArrayList<HarEntry>(log.getEntries());
System.out.println("entries"+entries);
for (HarEntry entry : entries)
System.out.println("entry="+entry.getRequest().getUrl());
File harFile = new File(HAR_FILE_PATH+"2"+".har");
File("/Users/yourpath/"+"2"+".har");
har.writeTo(harFile);
Thanks Tabish. Does this work in with Appium server as well? I noticed appium is not supported by BrowserMobProxy. Here is the link github.com/appium/appium/issues/4968. Do you have any suggestions?
– vm31
May 26 '16 at 18:39
I tried the apporach as well you mentioned, har file is generated without any information more than the basics. Here is the info. "log": "version": "1.2", "creator": "name": "BrowserMob Proxy", "version": "2.1.0-beta-3-littleproxy", "comment": "" , "pages": [ "id": "Second.har", "startedDateTime": "2016-05-26T21:42:46.453+02:00", "title": "Second.har", "pageTimings": "comment": "" , "comment": "" ], "entries": [], "comment": ""
– vm31
May 26 '16 at 19:48
Did you set up your phone to route its traffic via proxy port(8897 in the example)?
– Tabish Javed
May 27 '16 at 5:21
Yes Tried it that but app starts complaining that the network is being monitored. Also my app does not work on Rooted devices.
– vm31
May 28 '16 at 20:23
Any idea how can make my device listen to BrowserMobProxy server?
– vm31
Jun 1 '16 at 12:32
|
show 2 more comments
There are two possible ways of recording the network calls:
1) Set up proxy in your mobile via any of the proxy tool you use like charles, wireshark. What I mean is manually open whatever GUI tool you have and route your traffic via the tool as when you want to listen to network traffic.
2) Another way is through browsermob proxy. This would generate a HAR file of all the network calls that were made(would give the headers of the response and not JSON data).Maven Dependency is:
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-core-littleproxy</artifactId>
<version>2.1.0-beta-3</version>
</dependency>
Add this where you create your environment:
// Starting server BrowserMobProxy
server= new BrowserMobProxyServer();
server.setConnectTimeout(10, TimeUnit.SECONDS);
server.start(8897);
Proxy proxy = ClientUtil.createSeleniumProxy(server);
Set capabilities:
capabilities.setCapability(CapabilityType.PROXY, proxy);
After the driver is set up, create a HAR file
server.newHar("2.har");
In your @AfterSuite add below:
if(server.getHar()==null)
System.out.println("No Har capture");
Har har = server.getHar();
if(har==null)
System.out.println("Har is NULL");
FileOutputStream fos = new FileOutputStream(FILE_OUTPUT_HAR+"fos"+".har");
har.writeTo(fos);
HarLog log = har.getLog();
if(log==null)
System.out.println("Harlog is null");
List<HarEntry> entries = new CopyOnWriteArrayList<HarEntry>(log.getEntries());
System.out.println("entries"+entries);
for (HarEntry entry : entries)
System.out.println("entry="+entry.getRequest().getUrl());
File harFile = new File(HAR_FILE_PATH+"2"+".har");
File("/Users/yourpath/"+"2"+".har");
har.writeTo(harFile);
Thanks Tabish. Does this work in with Appium server as well? I noticed appium is not supported by BrowserMobProxy. Here is the link github.com/appium/appium/issues/4968. Do you have any suggestions?
– vm31
May 26 '16 at 18:39
I tried the apporach as well you mentioned, har file is generated without any information more than the basics. Here is the info. "log": "version": "1.2", "creator": "name": "BrowserMob Proxy", "version": "2.1.0-beta-3-littleproxy", "comment": "" , "pages": [ "id": "Second.har", "startedDateTime": "2016-05-26T21:42:46.453+02:00", "title": "Second.har", "pageTimings": "comment": "" , "comment": "" ], "entries": [], "comment": ""
– vm31
May 26 '16 at 19:48
Did you set up your phone to route its traffic via proxy port(8897 in the example)?
– Tabish Javed
May 27 '16 at 5:21
Yes Tried it that but app starts complaining that the network is being monitored. Also my app does not work on Rooted devices.
– vm31
May 28 '16 at 20:23
Any idea how can make my device listen to BrowserMobProxy server?
– vm31
Jun 1 '16 at 12:32
|
show 2 more comments
There are two possible ways of recording the network calls:
1) Set up proxy in your mobile via any of the proxy tool you use like charles, wireshark. What I mean is manually open whatever GUI tool you have and route your traffic via the tool as when you want to listen to network traffic.
2) Another way is through browsermob proxy. This would generate a HAR file of all the network calls that were made(would give the headers of the response and not JSON data).Maven Dependency is:
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-core-littleproxy</artifactId>
<version>2.1.0-beta-3</version>
</dependency>
Add this where you create your environment:
// Starting server BrowserMobProxy
server= new BrowserMobProxyServer();
server.setConnectTimeout(10, TimeUnit.SECONDS);
server.start(8897);
Proxy proxy = ClientUtil.createSeleniumProxy(server);
Set capabilities:
capabilities.setCapability(CapabilityType.PROXY, proxy);
After the driver is set up, create a HAR file
server.newHar("2.har");
In your @AfterSuite add below:
if(server.getHar()==null)
System.out.println("No Har capture");
Har har = server.getHar();
if(har==null)
System.out.println("Har is NULL");
FileOutputStream fos = new FileOutputStream(FILE_OUTPUT_HAR+"fos"+".har");
har.writeTo(fos);
HarLog log = har.getLog();
if(log==null)
System.out.println("Harlog is null");
List<HarEntry> entries = new CopyOnWriteArrayList<HarEntry>(log.getEntries());
System.out.println("entries"+entries);
for (HarEntry entry : entries)
System.out.println("entry="+entry.getRequest().getUrl());
File harFile = new File(HAR_FILE_PATH+"2"+".har");
File("/Users/yourpath/"+"2"+".har");
har.writeTo(harFile);
There are two possible ways of recording the network calls:
1) Set up proxy in your mobile via any of the proxy tool you use like charles, wireshark. What I mean is manually open whatever GUI tool you have and route your traffic via the tool as when you want to listen to network traffic.
2) Another way is through browsermob proxy. This would generate a HAR file of all the network calls that were made(would give the headers of the response and not JSON data).Maven Dependency is:
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-core-littleproxy</artifactId>
<version>2.1.0-beta-3</version>
</dependency>
Add this where you create your environment:
// Starting server BrowserMobProxy
server= new BrowserMobProxyServer();
server.setConnectTimeout(10, TimeUnit.SECONDS);
server.start(8897);
Proxy proxy = ClientUtil.createSeleniumProxy(server);
Set capabilities:
capabilities.setCapability(CapabilityType.PROXY, proxy);
After the driver is set up, create a HAR file
server.newHar("2.har");
In your @AfterSuite add below:
if(server.getHar()==null)
System.out.println("No Har capture");
Har har = server.getHar();
if(har==null)
System.out.println("Har is NULL");
FileOutputStream fos = new FileOutputStream(FILE_OUTPUT_HAR+"fos"+".har");
har.writeTo(fos);
HarLog log = har.getLog();
if(log==null)
System.out.println("Harlog is null");
List<HarEntry> entries = new CopyOnWriteArrayList<HarEntry>(log.getEntries());
System.out.println("entries"+entries);
for (HarEntry entry : entries)
System.out.println("entry="+entry.getRequest().getUrl());
File harFile = new File(HAR_FILE_PATH+"2"+".har");
File("/Users/yourpath/"+"2"+".har");
har.writeTo(harFile);
answered May 26 '16 at 4:55
Tabish JavedTabish Javed
1812 silver badges5 bronze badges
1812 silver badges5 bronze badges
Thanks Tabish. Does this work in with Appium server as well? I noticed appium is not supported by BrowserMobProxy. Here is the link github.com/appium/appium/issues/4968. Do you have any suggestions?
– vm31
May 26 '16 at 18:39
I tried the apporach as well you mentioned, har file is generated without any information more than the basics. Here is the info. "log": "version": "1.2", "creator": "name": "BrowserMob Proxy", "version": "2.1.0-beta-3-littleproxy", "comment": "" , "pages": [ "id": "Second.har", "startedDateTime": "2016-05-26T21:42:46.453+02:00", "title": "Second.har", "pageTimings": "comment": "" , "comment": "" ], "entries": [], "comment": ""
– vm31
May 26 '16 at 19:48
Did you set up your phone to route its traffic via proxy port(8897 in the example)?
– Tabish Javed
May 27 '16 at 5:21
Yes Tried it that but app starts complaining that the network is being monitored. Also my app does not work on Rooted devices.
– vm31
May 28 '16 at 20:23
Any idea how can make my device listen to BrowserMobProxy server?
– vm31
Jun 1 '16 at 12:32
|
show 2 more comments
Thanks Tabish. Does this work in with Appium server as well? I noticed appium is not supported by BrowserMobProxy. Here is the link github.com/appium/appium/issues/4968. Do you have any suggestions?
– vm31
May 26 '16 at 18:39
I tried the apporach as well you mentioned, har file is generated without any information more than the basics. Here is the info. "log": "version": "1.2", "creator": "name": "BrowserMob Proxy", "version": "2.1.0-beta-3-littleproxy", "comment": "" , "pages": [ "id": "Second.har", "startedDateTime": "2016-05-26T21:42:46.453+02:00", "title": "Second.har", "pageTimings": "comment": "" , "comment": "" ], "entries": [], "comment": ""
– vm31
May 26 '16 at 19:48
Did you set up your phone to route its traffic via proxy port(8897 in the example)?
– Tabish Javed
May 27 '16 at 5:21
Yes Tried it that but app starts complaining that the network is being monitored. Also my app does not work on Rooted devices.
– vm31
May 28 '16 at 20:23
Any idea how can make my device listen to BrowserMobProxy server?
– vm31
Jun 1 '16 at 12:32
Thanks Tabish. Does this work in with Appium server as well? I noticed appium is not supported by BrowserMobProxy. Here is the link github.com/appium/appium/issues/4968. Do you have any suggestions?
– vm31
May 26 '16 at 18:39
Thanks Tabish. Does this work in with Appium server as well? I noticed appium is not supported by BrowserMobProxy. Here is the link github.com/appium/appium/issues/4968. Do you have any suggestions?
– vm31
May 26 '16 at 18:39
I tried the apporach as well you mentioned, har file is generated without any information more than the basics. Here is the info. "log": "version": "1.2", "creator": "name": "BrowserMob Proxy", "version": "2.1.0-beta-3-littleproxy", "comment": "" , "pages": [ "id": "Second.har", "startedDateTime": "2016-05-26T21:42:46.453+02:00", "title": "Second.har", "pageTimings": "comment": "" , "comment": "" ], "entries": [], "comment": ""
– vm31
May 26 '16 at 19:48
I tried the apporach as well you mentioned, har file is generated without any information more than the basics. Here is the info. "log": "version": "1.2", "creator": "name": "BrowserMob Proxy", "version": "2.1.0-beta-3-littleproxy", "comment": "" , "pages": [ "id": "Second.har", "startedDateTime": "2016-05-26T21:42:46.453+02:00", "title": "Second.har", "pageTimings": "comment": "" , "comment": "" ], "entries": [], "comment": ""
– vm31
May 26 '16 at 19:48
Did you set up your phone to route its traffic via proxy port(8897 in the example)?
– Tabish Javed
May 27 '16 at 5:21
Did you set up your phone to route its traffic via proxy port(8897 in the example)?
– Tabish Javed
May 27 '16 at 5:21
Yes Tried it that but app starts complaining that the network is being monitored. Also my app does not work on Rooted devices.
– vm31
May 28 '16 at 20:23
Yes Tried it that but app starts complaining that the network is being monitored. Also my app does not work on Rooted devices.
– vm31
May 28 '16 at 20:23
Any idea how can make my device listen to BrowserMobProxy server?
– vm31
Jun 1 '16 at 12:32
Any idea how can make my device listen to BrowserMobProxy server?
– vm31
Jun 1 '16 at 12:32
|
show 2 more comments
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37433606%2fread-api-calls-of-app-with-appium%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown