Get browser version using selenium webdriver

前端 未结 8 1425
醉话见心
醉话见心 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:43

    While this may not quite answer the question above, this still could be useful to someone whose looking for a way to code a test based upon different behaviors they receive from different browsers (i.e. Firefox vs Chrome). I was looking for this at the time when I stumbled upon this thread, so I thought I'd add it in case it can help someone else.

    On Python, if you're simply looking for the browser you're testing on (i.e. firefox, chrome, ie, etc..), then you could use...

    driver.name
    

    ... in an if statement. This assumes you've already assigned driver to the web browser you're testing on (i.e. Firefox, Chrome, IE, etc..). However, if you're tasked with testing multiple versions of the same browser, you'll want something more to driver.version. Hope this helps someone out. I was looking for this solution when I found this thread, so I thought I'd add it just in case someone else needs it.

提交回复
热议问题