Get browser version using selenium webdriver

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

    If your wrapping your WebDriver so that it is EventFiring you'll have to do a custom EventFiringWebDriver implementation.

    import org.openqa.selenium.Capabilities;
    import org.openqa.selenium.HasCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.openqa.selenium.support.events.EventFiringWebDriver;
    
    public class MyEventFiringWebDriver extends EventFiringWebDriver implements HasCapabilities {
    
        private RemoteWebDriver driver;
    
        public MyEventFiringWebDriver(RemoteWebDriver driver) {
            super(driver);
            this.driver = driver;
        }
    
        @Override
        public Capabilities getCapabilities() {
            return driver.getCapabilities();
        }
    
    }
    

    Just posting because it was a problem I ran across.

    0 讨论(0)
  • 2020-12-06 09:54

    If you are using Chrome you can do the following:

    driver.capabilities['version']
    

    And if you are using Firefox:

    driver.capabilities['browserVersion']
    
    0 讨论(0)
提交回复
热议问题