【发布时间】:2018-04-06 19:19:08
【问题描述】:
我正在使用 chrome 选项来访问使用 selenium 的性能日志记录,我正在尝试编写一个代码来帮助我确定加载完成后 http 请求的总数和页面的大小。手动我们可以使用开发工具的网络选项卡来检查这一点。只需要知道如何访问网络表的值或汇总值。因为性能日志没有给我我需要的汇总值,所以我想写一个代码来获取:
请求总数=
页面的总权重是多少=
如果可能的话。
Screen shot of network tab highlighted the Summary and Request table values that i need to access
capabilities = DesiredCapabilities.CHROME
capabilities['loggingPrefs'] = {'browser': 'DEBUG'}
capabilities['loggingPrefs'] = {'performance': 'ALL'}
capabilities['perfLoggingPrefs'] = {'enableTimeline': 'true'}
driverLocation = "/Users/harisrizwan/Selenium/chrome/chromedriver"
os.environ["chrome.driver"] = driverLocation
chrome_options = Options()
chrome_options.add_argument("headless")
driver=
webdriver.Chrome(driverLocation,desired_capabilities=capabilities)
driver.implicitly_wait(10)
driver.maximize_window()
baseUrl="www.google.com"
driver.get(baseUrl)
使用 pandas 创建日志的数据框。
df = pd.DataFrame(driver.get_log('performance'))
df.to_clipboard(index=False)
谢谢。
【问题讨论】:
标签: java python-2.7 selenium automation google-chrome-devtools