首页 > 解决方案 > 如何在 Robot Framework 中获取 Firefox devtools Network 选项卡条目?

问题描述

我在我的机器人框架测试中面临以下问题。

在网站上进行一些测试期间,我需要捕获可以在 Firefox 开发人员工具网络选项卡中看到的日志(如以下屏幕中的示例)

在此处输入图像描述

我看到很多人建议使用 webdriver 实例的性能,所以我尝试使用:

def get_logsPerformance(driver):
  return driver.get_log("performance")

或使用 javascript:

driver.execute_script("var performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {}; var network = performance.getEntries() || {}; return network;")

但那些并没有给我我需要知道的东西:

我需要的不是所有的性能信息,而是网络信息,例如:

driver.get_log("network")

但它似乎不存在。

我怎样才能获得这些信息?是否可以通过使用 webdriver 的属性来获得它?我也读过 BrowserMobProxy 但我真的不知道如何设置它,以防万一一步一步或配置它的基本帮助真的很感激。希望有人能帮忙,非常感谢

标签: selenium-webdriverpython-requestsrobotframeworkfirefox-developer-toolsbrowsermob-proxy

解决方案


推荐阅读