ManRow
ManRow

Reputation: 1593

Mocking HTTP interaction with Selenium WebDriver

Is there a way to mock an http interaction/conversation with a selenium webdriver instance?

Suppose I want to point a WebDriver instance at some url "X" but want it to load some html "Y" instead --- without actually visting "X" at all (my application url "X" can be offline! But know what HTML its going to load anyway...). Is there a way I can do this? I mean, without creating a REAL http server to serve "Y" on some port?

Upvotes: 3

Views: 2026

Answers (2)

user3406366
user3406366

Reputation: 11

Xml mimic stub server can do it with few simple configuration, read the readme file for sample configuration.

http://sourceforge.net/projects/xmlmimic/

Upvotes: 0

Rafael Oltra
Rafael Oltra

Reputation: 1239

You could just create a (temp) file with the HTML contents, then create a URL object pointing to this file, and then just use WebDriver's get method on this URL

Upvotes: 1

Related Questions