I encountered an interesting challenge recently when doing Native Android / iOS app automation - this was related to Chrome browser versions getting updated automatically and my tests failing because of errors like:
So I asked a question on LinkedIn
And I tweeted asking how to manage ChromeDriver version when running WebDriver / Appium tests.
However, that was a partial answer for me.
Here is my context and problem statement in detail:
So I asked a question on LinkedIn
And I tweeted asking how to manage ChromeDriver version when running WebDriver / Appium tests.
I have a #appium / #java #framework.— Anand Bagmar (@BagmarAnand) September 20, 2019
What is a good way to keep #chromedriver updated with version of #chrome via #scripts? I do not want to do this manually - since I have 3+ #jenkins agents (#linux + #mac mini) and 7+ team members who need to keep doing this #osx #command
The answer was common and obvious – use WebDriverManager. This is a beautiful, simple and indeed the right answer and solution to the problem.
However, that was a partial answer for me.
Here is my context and problem statement in detail:
- My Test Automation Framework is based on Java / Appium and I use AppiumTestDistribution (ATD)
- ATD is open-source, and takes away my pain and effort of managing appium and the devices and also takes care of running the tests in parallel or distributed mode, on android as well as iOS
- In my local lab setup, I have many different android devices connected - which run tests as directed by ATD
- Since you cannot control how Google PlayStore / Apple App Store pushes out new versions of apps for different android / iOS versions on devices, it is easily possible to end up with different versions of chrome browser in your device lab. When this happens, the tests start failing because of chromedriver incompatibility issues.
Once I was very kindly reminded by the community about WebDriverManager (which I had forgotten about), I now knew what was to be done.
I looked at the ATD code, and realised that it was using the default chromedriver version as setup when I had installed appium. This chromedriver was being used when instantiating a new instance of the AndroidDriver.
So I submitted a PR for ATD - which essentially did the following:
- Query the chrome browser versions on each connected device
- For the **highest version of the browser, use WebDriverManager and get the appropriate chromedriver downloaded
- Pass the path to the correct chromedriver when creating an instance of the AndroidDriver
**highest version - what does that mean? Well, I also got confused initially. But the answer was simple. On some devices, the Chrome browser is installed by default, as a system app. This cannot be removed. So as new versions of the browser get installed, the default Chrome system app is always there. So when you query for the versions of Chrome on the device, you will see 2 such versions. My code logic was to get all these versions, and pick the highest version from them.
Here is the code snippet of how I solved the problem:
Hope this provides more information about my problem statement, and how I used your suggestion for WebDriverManager to solve the problem.