Reputation: 479
I'm trying to get the version number of whatever version of Chrome is installed on the device i am performing mobile automated web testing on.
Currently i have:
desired_caps = {
caps: {
platformName: 'Android',
versionNumber: '7.0',
deviceName: 'S7 Edge',
device: "Android",
browserName: "Chrome"
}
}
@driver = Appium::Driver.new(desired_caps).start_driver
@driver.get('https://www.google.com')
puts @driver.capabilities.version
But this returns an empty string. I understand there is a capability named 'version', but adding this to the capabilities like version: 'latest'
just returns 'latest'
and not the version of Chrome which is installed on the device.
Any ideas?
Upvotes: 2
Views: 1474
Reputation: 42538
With Chrome you could try to navigate to chrome://version/
and parse the number:
driver.get("chrome://version/")
puts driver.execute_script("return document.querySelector('td span').innerText")
> 62.0.3202.89
You could also get the version direcly from the User-Agent:
version = driver.execute_script("return navigator.userAgent.match('Chrome/[^ ]+')[0]")
puts version
> Chrome/62.0.3202.89
Upvotes: 2