Col*_*McC 5 python logging selenium selenium-chromedriver remotewebdriver
我正在尝试从远程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);
Run Code Online (Sandbox Code Playgroud)
看起来它应该做我需要的.但它是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']
Run Code Online (Sandbox Code Playgroud)
(在两个添加的命令'getAvailableLogTypes'和'getLog'中 - 您只在上面的代码片段中看到前者.后者只返回远程会话中可用日志类型的列表.)
现在我需要做的只是解释它....
| 归档时间: |
|
| 查看次数: |
2790 次 |
| 最近记录: |