How to manipulate /etc/hosts file on each test machine and tests running in parallel?



  • Most developers and testers usually takes advantage of Operation System Host File (commonly known as "hosts") to "trick" the S.O. and the browser to load websites and webservices from another server than the real production one. It's a very easy approach to be able to use the production host name of your site or service while pointing your computer to another server (staging, Q&A, etc). This is acceptable when testing manually, but constrains test automation because I need to manipulate /etc/hosts file on each test machine and tests running in parallel may be impacted by this change. Is there a way to create a browser with mapping specific only for this browser instance? Something like WebDriver capabilities? I know there are relevant plugins for Firefox ("Change Hosts"), but this makes my tests browser-specific.



  • oh ok, that's a tricky one. This is what I know regarding this subject, see if it can help: - only after you close the browser the changes you made take effect - maybe you could, instead of using the hosts, use the name of the pc that has the app running, we do it in my company. I.E. PC1 has the app, instead of puting the ip and the url on the hosts file, you can just put the url on the browser http : // PC1 /... Before editing.... Sorry for the reply, but I can't comment... Can't you just write a function (C#, Java, etc...) to change the hosts file?



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2