Selenium: Is there a way to change the hosts file on the machine the server is running on

StackOverflow https://stackoverflow.com/questions/2131766

  •  22-09-2019
  •  | 
  •  

Question

I want to make the browser open a local url with a name of the live url. Meaning that when I do:

sel.open('http://live-url/)

selenium will actually open the local url.

One would test this by changing it's hosts file but this is impossible when running on many machines.

ideas?

Was it helpful?

Solution

No

Selenium cannot change the hosts file as it can only interact with pages rendered inside a broswer.

You could probably set your CI server up to do something like this, but again I have to ask why. Hacking around with a site and then testing it will surely invalidate your tests?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top