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
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top