When I started out on my crazy adventures in test automation, I stayed close to the browser. The first automation framework I worked in was WATIR and it was awesome. It is a clean and straightforward framework which is what drew me to it. I was introduced to my first headless automation tool by one of our UI Engineers. The tool set was CasperJS and PhantomJS. While they were great tools, I really wasn’t sure how to use them correctly, especially since I wasn’t watching my tests execute anymore. So I played with them for a while and that was it.
Today’s Code Snippet is for using a JSON configuration file with CapserJS and PhantomJS. I have been using JSON configuration files with my test automation for a while now to help manage test URLs, user agents, users, etc. It is a great way to make your automation more flexible and update settings for an entire application. Below is an example of how your configuration file would look.