Skip to content

Commit b73d8a2

Browse files
authored
New appium + "interceptor: getInterceptedData" (#69)
* getInterceptedData * Appium3.0 * hotfix_issue70
1 parent 8e001a6 commit b73d8a2

File tree

7 files changed

+10835
-10282
lines changed

7 files changed

+10835
-10282
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This plugin uses mitmproxy
55

66
## Prerequisite
77

8-
1. Appium version 2.0
8+
1. Appium version 3.0
99
2. Intercepting API requests from android requires CA certificate to be installed on the device. Follow the instructions in [How to install CA certificate on android](./docs/certificate-installation.md) section and install the CA certificate.
1010

1111
## Installation - Server

docs/commands.md

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ Add a new mock specification for intercepting and updating the request. The comm
4848

4949

5050
```javascript
51-
const authorizationMock = await driver.execute("interceptor: addMock", [{
51+
const authorizationMock = await driver.execute("interceptor: addMock", {
5252
config: {
5353
url: "**/reqres.in/**",
5454
headers: {
5555
"Authorization" : "Bearer bearertoken"
5656
}
5757
}
58-
}]);
58+
});
5959

60-
const userListGetMock = await driver.execute("interceptor: addMock", [{
60+
const userListGetMock = await driver.execute("interceptor: addMock", {
6161
config: {
6262
url: "**/reqres.in/api/users",
6363
method: "GET",
@@ -76,7 +76,7 @@ Add a new mock specification for intercepting and updating the request. The comm
7676
]
7777
})
7878
}
79-
}]);
79+
});
8080
```
8181

8282
`authorizationMock` will be executed for all api calls made to `reqres.in` domain and `userListGetMock` will be applied for `https://www.reqres.in/api/users` with `GET` http method.
@@ -87,23 +87,23 @@ Given a mockId return during addMock command, will remove the mock configuration
8787
#### Example:
8888

8989
```javascript
90-
const authorizationMock = await driver.execute("interceptor: addMock", [{
90+
const authorizationMock = await driver.execute("interceptor: addMock", {
9191
config: {
9292
url: "**/reqres.in/**",
9393
headers: {
9494
"Authorization" : "Bearer bearertoken"
9595
}
9696
}
97-
}]);
97+
});
9898

9999
//peform user action
100100
//perform validation
101101
..
102102
..
103103

104-
await driver.execute("interceptor: removeMock", [{
104+
await driver.execute("interceptor: removeMock", {
105105
id: authorizationMock
106-
}]);
106+
});
107107

108108
// authorizationMock will not be active after this point and the test will proceed with normal flow
109109
```
@@ -123,45 +123,45 @@ Start listening for all network traffic (API calls) made by the device during a
123123
It also supports filtering the request based on the url. `include` will only listents for requests that macthes the given url pattern and `exclude` will listen for all api's that doesn't match the url pattern.
124124

125125
```javascript
126-
await driver.execute("interceptor: startListening", [{
126+
await driver.execute("interceptor: startListening", {
127127
config: {
128-
include : {
128+
include : [{
129129
url: "**/reqres.in/**",
130-
}
130+
}]
131131
}
132-
}]);
132+
});
133133
// perform some action
134134
// ...
135135
```
136136

137137
```javascript
138-
await driver.execute("interceptor: startListening", [{
138+
await driver.execute("interceptor: startListening", {
139139
config: {
140-
exclude : {
140+
exclude : [{
141141
url: "**/reqres.in/**",
142-
}
142+
}]
143143
}
144-
}]);
144+
});
145145
// perform some action
146146
// ...
147147
```
148148

149-
### interceptor: stopListening
149+
### interceptor: getInterceptedData
150150

151-
Stops listening for networks traffic and return all previously recorded api calls.
151+
Return all previously recorded api calls.
152152

153153
#### Example:
154154

155155
```javascript
156156
await driver.execute("interceptor: startListening");
157157
// perform some action
158158
// ...
159-
const apiRequests = await driver.execute("interceptor: stopListening");
159+
const apiRequests = await driver.execute("interceptor: getInterceptedData");
160160
```
161161

162162
#### Returns:
163163

164-
stopListening command will retunrs an array of network details in the below JSON format
164+
getInterceptedData command will return an array of network details in the below JSON format
165165

166166
```javascript
167167
[
@@ -251,6 +251,23 @@ stopListening command will retunrs an array of network details in the below JSON
251251
]
252252
```
253253

254+
### interceptor: stopListening
255+
256+
Stops listening for networks traffic and return all previously recorded api calls.
257+
258+
#### Example:
259+
260+
```javascript
261+
await driver.execute("interceptor: startListening");
262+
// perform some action
263+
// ...
264+
const apiRequests = await driver.execute("interceptor: stopListening");
265+
```
266+
267+
#### Returns:
268+
269+
stopListening command will return an array of network details in the same format than getInterceptedData.
270+
254271
### Java Example
255272
```
256273
Map<String, String> config = new HashMap();

0 commit comments

Comments
 (0)