質問

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):

  • Use the IP in the call - This does not work, see above.
  • Make my own call in the test system after my login - The URL in step 3 is dynamic defined, and it is a unwanted modification in my test sequence.
  • Integrate the hosts file change in my test. - With this solution my test must run as admin to change the hosts file (I'm on Win7).

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

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top