knut
knut

Reputation: 27855

Watir: Alternative to change the hosts file?

I use watir to test a test version of a website. To do so, I have to modify my hosts-file

Is there a way to get the same result without modifying the hosts file?

The obvious idea to replace the domain with the ip-address in the calling uri does not work.

Background:

I define my hosts like

10.10.10.10 http://www.example.net/

Then I test:

  1. I call http://www.example.net/myapp
  2. The website redirects to a login page and I enter my credits (automated).
  3. After the authorization check, the site calls again http://www.example.net/myapp_auth.

This call in step 3 is no relative call (a subpage of the actual domain) but a call with full url. Without the hosts change, my test with http://10.10.10.10/myapp would make the authorization test in my test system (10.10.10.10) and then call the productive system on http://www.example.net/.

My ideas up to now (and why I don't use them):

So my question: Is there a way to use watir with a kind of internal hosts file?

Upvotes: 1

Views: 3393

Answers (1)

mikeryz
mikeryz

Reputation: 527

You could set up a simple DNS server using something such as rubydns, add this on localhost to your DNS lookup list. If it is not there, DNS lookup should fall through (and quickly on the local loopback), if it is there, you can direct example.net back to localhost for all callers on your machine.

Upvotes: 2

Related Questions