Mic*_*jek 6 selenium google-chrome-devtools selenium-chromedriver selenium-webdriver
希望通过chromedriver启用“保留日志”。 https://sites.google.com/a/chromium.org/chromedriver/capabilities loggingPrefs指向Google代码存档页面,并不是很有用。
我的总体目标是在测试执行期间解析日志以查找错误,但是日志会在页面导航中清除,这在测试期间可能会发生多次。
我可以想到几个非理想的解决方法:
两者都不理想,因此正在寻找最简单的方法。
这个问题类似于使用chromedriver以编程方式在chrome中启用“保留日志” -但是在那儿,答案似乎是关于通过性能日志记录重定向重定向,而不是保留导航日志。
小智 -1
//chromedriver\xef\xbc\x8cpreserve log\n// request postdata\nChromeOptions chromeOptions = new ChromeOptions();\n//HAR\nArrayList<String> excludeSwitches = new ArrayList<>();\nexcludeSwitches.add("enable-automation");\nchromeOptions.setExperimentalOption("excludeSwitches",excludeSwitches);\nList<HarEntry> list = har.getLog().getEntries();\nfor (HarEntry harEntry : list){\n HarRequest request = harEntry.getRequest();\n if(request != null){\n String requestBody = request.getPostData().getText();\n System.out.println("requestBody:" + requestBody);\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1096 次 |
| 最近记录: |