generated from AppiumTestDistribution/appium-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update java example to use Hashmap (#28)
- Loading branch information
1 parent
af903d8
commit 03ab1dc
Showing
1 changed file
with
18 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -253,26 +253,24 @@ stopListening command will retunrs an array of network details in the below JSON | |
|
||
### Java Example | ||
``` | ||
JSONObject customObject = new JSONObject(); | ||
customObject.put("url","/api/users?.*"); | ||
customObject.put("responseBody","{\n" + | ||
" \"page\": 2,\n" + | ||
" \"per_page\": 6,\n" + | ||
" \"total\": 12,\n" + | ||
" \"total_pages\": 2,\n" + | ||
" \"data\": [\n" + | ||
" {\n" + | ||
" \"id\": 7,\n" + | ||
" \"email\": \"[email protected]\",\n" + | ||
" \"first_name\": \"Michael\",\n" + | ||
" \"last_name\": \"Lawson\",\n" + | ||
" \"avatar\": \"https://reqres.in/img/faces/7-image.jpg\"\n" + | ||
" }\n" + | ||
" ]\n" + | ||
"}"); | ||
JSONObject parentJson = new JSONObject(); | ||
parentJson.put("config", customObject); | ||
driver.executeScript("interceptor: addMock",new JSONObject(parentJson)); | ||
Map<String, String> config = new HashMap(); | ||
config.put("url", "/api/users?.*"); | ||
config.put("responseBody","{\n" + | ||
" \"page\": 2,\n" + | ||
" \"per_page\": 6,\n" + | ||
" \"total\": 12,\n" + | ||
" \"total_pages\": 2,\n" + | ||
" \"data\": [\n" + | ||
" {\n" + | ||
" \"id\": 7,\n" + | ||
" \"email\": \"[email protected]\",\n" + | ||
" \"first_name\": \"Michael\",\n" + | ||
" \"last_name\": \"Lawson\",\n" + | ||
" \"avatar\": \"https://reqres.in/img/faces/7-image.jpg\"\n" + | ||
" }\n" + | ||
" ]\n" + | ||
"}"); | ||
((JavascriptExecutor)DriverManager.getDriver()).executeScript("interceptor: addMock",config); | ||
driver.findElement(By.xpath("//android.widget.TextView[contains(@text,'List')]")).click(); | ||
``` | ||
|
||
|