HTML page got returned as part of API response in karate. Now how to enter username and password on that?

Viewed 57

I have an API which redirects to browser and on that we have to enter username and password.

The API returns the HTML page as part of the response. How from HTML response we can pick username and password via locator Id and click button?

I have tried below but as it is returned in the response I somehow need to tell where in response find that field and input.

   And input('#username', 'username')
   And input('#password', 'password')
   When click('#kc-login')

1 Answers

What I would do is scrape any information needed out of the HTML like this: https://stackoverflow.com/a/61605535/143475

And then form an HTTP request to do what the clicking of the button actually does. Remember no matter what HTML and complex JS / UI you see, finally everything becomes some HTTP request. Use the developer tools "network" part of the browser to figure this out.

The rest is up to your creativity. Work with some web-developers if required.

Related