java - 为什么在 selenium 网格中使用 chrome remotewebdriver 时无法捕获网络日志?
问题描述
你好 Stackoverflow 社区,
我想在使用 Selenium Grid 的 Web 自动化测试时捕获网络流量(实际上,我正在使用 VM 来部署 selenium 网格架构(集线器和节点))。下面是我用来获取网络日志的代码:
ChromeOptions chromeOptions = new ChromeOptions();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.PERFORMANCE, Level.INFO);
chromeOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
chromeOptions.setCapability("platform", platform);
chromeOptions.addArguments(
"--headless",
"--verbose",
"--disable-web-security",
"--allow-insecure-localhost",
"--ignore-certificate-errors",
"--allow-running-insecure-content",
"--no-sandbox",
"--disable-popup-blocking",
"--disable-dev-shm-usage",
"--ignore-certificate-errors",
"--silent"
);
this.driver = new RemoteWebDriver(new URL("http://172.20.10.10:4444/wd/hub"), chromeOptions);
this.driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
this.driver.manage().window().maximize();
this.driver.get(website);
List<LogEntry> entries = driver.manage().logs().get(LogType.PERFORMANCE).getAll();
System.out.println(entries.size() + " " + LogType.PERFORMANCE + " log entries found");
for (LogEntry entry : entries) {
System.out.println(new Date(entry.getTimestamp()) + " " + entry.getLevel() + " " + entry.getMessage());
}
但我得到这个错误:
Exception in thread "main" org.openqa.selenium.InvalidArgumentException: invalid argument: log type 'performance' not found
(Session info: headless chrome=78.0.3904.108)
System info: host: 'themadmalik', ip: '***.***.***.***', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.2'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 78.0.3904.108, chrome: {chromedriverVersion: 78.0.3904.105 (60e2d8774a81..., userDataDir: /tmp/.com.google.Chrome.tNFy6o}, goog:chromeOptions: {debuggerAddress: localhost:45465}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webdriver.remote.sessionid: 06521c2b5573343d789ba1302c4...}
有人知道我该如何解决这个问题?
谢谢!
解决方案
推荐阅读
- spring-session - 使用 Spring Session for Pivotal GemFire 时如何在 GemFire Pulse/Gfsh 中查看会话属性?
- excel - VB.Net:从项目中的数据文件获取文件路径
- visual-studio - Visual Studio 2017 - 将项目同步到 Github 存储库时出现问题
- react-native - 反应原生构建失败
- clang - 构建 clang 和相关工具的发布(非主干)版本
- google-search-console - 从新的 Google 网站管理员控制台中删除站点地图
- java - Java 如何使用通配符搜索模式?
- apache-spark - 火花数据帧写入问题
- jmeter - 如何使用 JSON 提取器从请求响应中正确提取 .pem 密钥
- procmail - 基于用户名的自动 procmail 过滤器