In one of my test case I hit the rest API using restAssured and the API always returns the response in pure HTML. The returned HTML is basically the source of a valid page. Now I can't use webDriver.get(URL); method since I don't have a direct URL.

Does selenium provide any such method in which I can open the HTML source directly in the browser instead of providing a URL?

  • I am not able to understand the why would you need webdriver methods in rest assured. Your problem statement is not very clear. Can you rephrase it. Sep 26, 2017 at 12:26

1 Answer 1


The basic idea is to just open a blank page and then set the inner HTML of the current page:

String innerHtml = "your HTML here";
driver.executeScript("document.innerHTML = " + innerHtml);

Or, you can also save that HTML into a file and then open the file via file:// protocol:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.