Hey everyone,
Just want to pass this little this little tid bit that might make your automation experience easier.
One of the things that causes headaches for test automation is when Browsers update. It can cause a whole range of issue from you requiring to update to latest selenium versions and drivers to something beginning to simply fail. A simple example is a case in recen Chrome 57 where .maximize() method (or any browser resizing) now gives an exception which requires the browser start up to be maximized by default. In a nutshell, it is always good to control the update of Browser so it would be a controlled one rather than unpredictable. Here are the two ways to do it:
1. Stop Autoupdate
One of the more simpler ways is to stop auto-update for the browsers. That way you will always have the version that you currently have on your computer/agent box and nothing new will all of a sudden appear to wreck your day.
The only problem with this solution is that if someone else will start using automation (or you spin up another agent) then they will by default get whatever browser they currently have on it which could be a version you are not supporting. That's why I prefer the second solution:
2. Point at a specific version of a Browser
You can point Selenium at a specific binary of a browser to start up which can be a version that you need. That way you will always point at a specific version of the browser and can even deploy other specific versions to test your automation code with. I will use Chrome as an example.
- Download and install older version of Chrome (which will work in parallel with your current Chrome). There is no official website that does that unfortunately so I had to do it from this website: https://www.slimjet.com/chrome/google-chrome-old-version.php
- Modify/Add ChromeOptions to use that binary instead of default one (actions\selenium\Brwoser.groovy), here is a code example (assuming that the version of the chrome was 56 and deployed to autbrowsers directory under C: or root if mac):
DesiredCapabilities capabilities = DesiredCapabilities.chrome()
ChromeOptions options = new ChromeOptions()
if(os.contains("mac")){options.setBinary("/autobrowsers/Chrome.app/Contents/MacOS/Google Chrome")}
else{options.setBinary("c:\\autobrowsers\\chrome64_56.0.2924.87\\chrome.exe")}
capabilities.setCapability(ChromeOptions.CAPABILITY, options)
Driver = new RemoteWebDriver(service.getUrl(),capabilities)
- Run the automation and it will now use this binary instead of your currently installed version of chrome