Skip to content

Commit a36bed4

Browse files
authored
Java Mock Example (#24)
* added intercept example for java * rm desired capabilities from the java example
1 parent edd6bf7 commit a36bed4

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/commands.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,29 @@ stopListening command will retunrs an array of network details in the below JSON
251251
]
252252
```
253253

254+
### Java Example
255+
```
256+
JSONObject customObject = new JSONObject();
257+
customObject.put("url","/api/users?.*");
258+
customObject.put("responseBody","{\n" +
259+
" \"page\": 2,\n" +
260+
" \"per_page\": 6,\n" +
261+
" \"total\": 12,\n" +
262+
" \"total_pages\": 2,\n" +
263+
" \"data\": [\n" +
264+
" {\n" +
265+
" \"id\": 7,\n" +
266+
" \"email\": \"michael.test@reqres.in\",\n" +
267+
" \"first_name\": \"Michael\",\n" +
268+
" \"last_name\": \"Lawson\",\n" +
269+
" \"avatar\": \"https://reqres.in/img/faces/7-image.jpg\"\n" +
270+
" }\n" +
271+
" ]\n" +
272+
"}");
273+
JSONObject parentJson = new JSONObject();
274+
parentJson.put("config", customObject);
275+
driver.executeScript("interceptor: addMock",new JSONObject(parentJson));
276+
driver.findElement(By.xpath("//android.widget.TextView[contains(@text,'List')]")).click();
277+
```
278+
279+

0 commit comments

Comments
 (0)