我正在尝试从远程 Webdriver 实例获取一些性能日志信息。我正在使用 Python Selenium 绑定。
据我看来,这是我应该能够拿回的信息。认为它可能仅适用于 ChromeDriver。我目前正在使用 FireFox,但如果它获得我想要的信息,我可以轻松切换。
然而,我是 Python 新手(但正在学习!),并且有关 Python 功能字典(用于性能日志记录时)的文档似乎有点有限(或者我的 google-fu 今天早上很弱)。
我发现了以下内容:
DesiredCapabilities caps = DesiredCapabilities.chrome();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable("performance", Level.INFO);
caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
driver = new RemoteWebDriver("http://localhost:9515", caps);
看起来它应该可以满足我的需要。但这是Java。我不太确定如何将其转换为 Python。假设这是可能的。
有任何想法吗?
如果有人想知道,这似乎对我有用:
(假设您使用的是硒遥控器)
url = 'http://remote instance IP:PORT/wd/hub'
descaps = {'browserName': 'chrome', 'loggingPrefs': {'performance': 'INFO'}}
driver = webdriver.Remote(command_executor=url, desired_capabilities=descaps)
driver.command_executor._commands.update({'getAvailableLogTypes':
('GET', '/session/sessionId/log/types'),
{'getLog': ('POST', '/session/$sessionId/log')})
getlog = driver.execute('getLog', {'type': 'performance'})['value']
(在两个添加的命令“getAvailableLogTypes”和“getLog”中,您只能在上面的代码片段中看到前者。后者仅返回远程会话上可用日志类型的列表。)
现在我需要做的就是解释它......
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)