Automation techniques: Enabling API verifications in a native App
This post is a sequel to my earlier post on enabling level-1 verifications. Read through it for the problem statement
More concretely the app in question godaddy investor, has views for list of domains and a domain details view.
The purpose of the test is to click on the favorite icon and verify that favoriting worked. The Action part (2) has to be done through the U but can the assertion — verifying action worked can be done through the API. But how?
If we take a closer look at our app through appium inpsector. It would look something like this
Now, if we add in a test hook to expose the listingid say as the containers value, our problem will be solved. Care has to be taken that this is the unique listing id and that we can get to the listing details based on the id.
Then we can query our API to verify that indeed the listing has the domain favorited. So in entirely code would look something along these lines
var listing_id = driver.getElement(‘container’).value
var response = request(‘http://godaddyapi.com/listings'+listing_id).to_json
assert (response[‘favorite’], true)
Obviously, this is an oversimplified example and asserting through the UI is likely faster but I am using this example to illustrate the concept.