Get browser version using selenium webdriver

前端 未结 8 1418
醉话见心
醉话见心 2020-12-06 09:06

How would I get the browser version being used?

>>> from selenium import webdriver
>>> driver = webdriver.Firefox()
>>> print vers         


        
8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 09:32

    If driver.capabilities['version'] does not work for you, check the capabilities. The version number is there but it might be under a different key. For example I was getting a key error on Windows 10 when trying to access the version number with the version key.

    To check capabilities:

    print driver.capabilities
    

    For me, this works on Chrome/Linux

    driver.capabilities['version']
    

    And this works on Chrome/Windows 10

    driver.capabilities['browserVersion']
    

提交回复
热议问题