Issue
I'm trying to write in some defensive code to prevent someone from executing a script should they have an older version of geckodriver installed. I cannot for the life of me seem to get the geckodriver version from the webdriver object.
The closest I found is driver.capabilities
which contains the firefox browser version, but not the geckodriver version.
from selenium import webdriver
driver = webdriver.Firefox()
pprint(driver.capabilities)
output:
{'acceptInsecureCerts': True,
'browserName': 'firefox',
'browserVersion': '60.0',
'moz:accessibilityChecks': False,
'moz:headless': False,
'moz:processID': 18584,
'moz:profile': '/var/folders/qz/0dsxssjd1133p_y44qbdszn00000gp/T/rust_mozprofile.GsKFWZ9kFgMT',
'moz:useNonSpecCompliantPointerOrigin': False,
'moz:webdriverClick': True,
'pageLoadStrategy': 'normal',
'platformName': 'darwin',
'platformVersion': '17.5.0',
'rotatable': False,
'timeouts': {'implicit': 0, 'pageLoad': 300000, 'script': 30000}}
Is it possible the browser version and geckodriver versions are linked directly? if not, how can I check the geckodriver version from within python?
Solution
There is no method in the python bindings to get the geckodriver version, you will have to implement it yourself, my first option would be subprocess
# Mind the encoding, it must match your system's
output = subprocess.run(['geckodriver', '-V'], stdout=subprocess.PIPE, encoding='utf-8')
version = output.stdout.splitlines()[0].split()[-1]
Answered By - Dalvenjia
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.