I run integration test with Selenium as a test runner and webdriver.io javascript library for Selenium API. My test goes as follows: I load an html page and click on a button. I want to check if a Get REST call was invoked.
I found a plugin for webdriver.io called webdriverajax that intend to fit to my requirements but it just doesn't work.
Any ideas how do capture rest calls?
You can achieve this by using custom
HttpClient
class that is out side from selenium code.As far as i know selenium doesn't support this feature.Assume when you clicked the button it will called a
REST
service , the URL can be grab from theHTML
DOM
element.Then you can use your custom code to verify if URL is accessible or not.Then you can decide if your test is pass or failed based on thestatus code
or some other your mechanism.FileDownloader.java(Sample code snippet)
TestClass.java
Here is the reference.
Note: This may not exactly fit into your requirement but you can get some idea and modify it accordingly to fit into your requirement.
Also refer the BrowserMob Proxy using this you can also achieve what you want.