After writing some web tests with Selenium, I need now to test REST APIs. I would like to drive my browser with Selenium and to verify the results displayed in my web browser with the results generated when I launch my API urls. My API URLs are in HTTP mode and the answer will be in JSON format.
I have found rest-assured : https://code.google.com/p/rest-assured/ But before jumping and use it I would like to know if it's easy to integrate it with my selenium tests and if there's a better alternative.
Thanks
You can force Selenium to wait for results to become available in the DOM. So yes, Selenium is a good tool to use to test your REST calls especially if your results update the HTML displayed on the page.
WebDriver driver = new FirefoxDriver();
driver.get("http://somedomain/url_that_delays_loading");
WebElement myDynamicElement = (new WebDriverWait(driver, 10))
.until(ExpectedConditions.presenceOfElementLocated(By.id("myDynamicElement")));
See the following page for more examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With