我的selenium脚本(用perl编写)正在使用/运行firefox,chrome和IE,正如我所期望的那样。我写了自己的" Testrun日志"这也没关系。几天前,我有想法包含硒驱动程序版本。 selenium独立服务器版本可通过" $ driver-> status"获得。如果我的脚本在chrome上运行,我会通过" $ driver-> get_capabilities()"找到版本信息。但是因为我没有找到版本号。 对于chrome我来说像哈希:
{
acceptSslCerts JSON::PP::Boolean {
Parents Types::Serialiser::BooleanBase
public methods (0)
private methods (0)
internals: 1
},
applicationCacheEnabled JSON::PP::Boolean {
Parents Types::Serialiser::BooleanBase
public methods (0)
private methods (0)
internals: 0
},
browserConnectionEnabled var{applicationCacheEnabled},
browserName "chrome",
chrome {
chromedriverVersion "2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed)",
userDataDir "C:\Users\me\AppData\Local\Temp\scoped_dir8684_28008"
},
cssSelectorsEnabled var{acceptSslCerts},
databaseEnabled var{applicationCacheEnabled},
handlesAlerts var{acceptSslCerts},
hasTouchScreen var{applicationCacheEnabled},
javascriptEnabled var{acceptSslCerts},
locationContextEnabled var{acceptSslCerts},
mobileEmulationEnabled var{applicationCacheEnabled},
nativeEvents var{acceptSslCerts},
networkConnectionEnabled var{applicationCacheEnabled},
pageLoadStrategy "normal",
platform "XP",
rotatable var{applicationCacheEnabled},
takesHeapSnapshot var{acceptSslCerts},
takesScreenshot var{acceptSslCerts},
version "54.0.2840.99",
webdriver.remote.sessionid "eb545ef9-6a1b-4297-a239-ca595bafbec1",
webStorageEnabled var{acceptSslCerts}
}
因为我得到:
{
browserAttachTimeout 0,
browserName "internet explorer",
cssSelectorsEnabled JSON::PP::Boolean {
Parents Types::Serialiser::BooleanBase
public methods (0)
private methods (0)
internals: 1
},
elementScrollBehavior 0,
enableElementCacheCleanup var{cssSelectorsEnabled},
enablePersistentHover var{cssSelectorsEnabled},
ie.browserCommandLineSwitches "",
ie.enableFullPageScreenshot var{cssSelectorsEnabled},
ie.ensureCleanSession JSON::PP::Boolean {
Parents Types::Serialiser::BooleanBase
public methods (0)
private methods (0)
internals: 0
},
ie.fileUploadDialogTimeout 3000,
ie.forceCreateProcessApi var{ie.ensureCleanSession},
ie.forceShellWindowsApi var{ie.ensureCleanSession},
ignoreProtectedModeSettings var{ie.ensureCleanSession},
ignoreZoomSetting var{ie.ensureCleanSession},
initialBrowserUrl "http://localhost:48881/",
javascriptEnabled var{cssSelectorsEnabled},
nativeEvents var{cssSelectorsEnabled},
pageLoadStrategy "normal",
platform "WINDOWS",
requireWindowFocus var{ie.ensureCleanSession},
takesScreenshot var{cssSelectorsEnabled},
unexpectedAlertBehaviour "dismiss",
version 11,
webdriver.remote.sessionid "b630495e-70fe-4d68-b4e4-cb24a57acab3"
}
但这里没有" chromedriverVersion"。 有没有人知道如何获得IEDriver的版本?
答案 0 :(得分:1)
因此,我不确定您是否希望记录WebDriver版本或浏览器版本。如果是后者,则会在您的问题的两个输出中打印版本。
如果您希望记录webdriver版本,那么IE驱动程序在功能列表中看起来并不具有驱动程序版本(请参阅:DesiredCapabilities documentation和ChromeDriver Capabilities documentation)。据我所知,这些页面上列出的属性是您可以从WebDriver中读取的唯一属性。
您可以尝试(在Java中,但我想这个方法在Perl中类似)
driver.getCapability("InternetExplorerDriver.version"); // or something like this,
但据我所知,没有可供查询的IE驱动程序版本。