我已经在机器人框架中编写了这个脚本。
Set Selenium Implicit Wait 10
## Init BrowserMob Proxy
${file} Join Path ${EXECDIR} browsermob-proxy-2.1.4 bin browsermob-proxy.bat
File Should Exist ${file}
Start Local Server ${file}
# Create dedicated proxy on BrowserMob Proxy
${BrowserMob_Proxy}= Create Proxy
# Configure Webdriver to use BrowserMob Proxy
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${options} add_argument --proxy\=${BrowserMob_Proxy}
Create WebDriver Chrome chrome_options=${options}
New Har google
Go To ${PAGE_URL}
Title Should Be Google
${har}= Get Har As Json
Create File ${EXECDIR}${/}file.har ${har}
Close All Browsers
Stop Local Server
但是当我尝试通过 HAR 分析器进行验证时,它返回错误说在文件中找不到日志条目。
处理 HAR 文件时发现错误:在文件中找不到日志条目。
哈尔的结果:
{"log": {"comment": "", "entries": [], "version": "1.2", "pages": [{"pageTimings": {"comment": ""}, "comment": "", "title": "google", "id": "google", "startedDateTime": "2017-03-23T10:26:27.317+08:00"}], "creator": {"comment": "", "version": "2.1.4", "name": "BrowserMob Proxy"}}}