您的位置:首页 > 理论基础 > 计算机网络

webdriver.Chrome.set_network_conditions:Chrome网络仿真设置。

2020-04-01 18:35 1126 查看

参数

print(webdriver.Chrome.set_network_conditions.__doc__)
"""
Sets Chrome network emulation settings.

:Args:
- network_conditions: A dict with conditions specification.

:Usage:
driver.set_network_conditions(
offline=False,
latency=5,  # additional latency (ms)
download_throughput=500 * 1024,  # maximal throughput
upload_throughput=500 * 1024)  # maximal throughput

Note: 'throughput' can be used to set both (for download and upload).
"""

参数:

  • offline

网络状态设置,默认为Fales(不断网),True(断网)

  • latency

网络延迟设置,默认5ms

  • download_throughput

下载最大吞吐量500 * 1024 500KB

  • upload_throughput

上行速率最大吞吐量500 * 1024 500KB

Note: ‘throughput’ can be used to set both (for download and upload).

  • throughput

可以直接设置上下行网络速率

实例说明

Broswer = webdriver.Chrome(executable_path="chromedriver", port=0,
options=None, service_args=None,
desired_capabilities=None, service_log_path=None,
chrome_options=None, keep_alive=True)
Broswer.set_network_conditions(offline=False,latency=1000,throughput=500 * 1024)
print(Broswer.get_network_conditions())
"""
{'download_throughput': 512000,
'latency': 1000,
'offline': False,
'upload_throughput': 512000}
"""

Note
: 使用Broswer.get_network_conditions() 前一定要设置Broswer.set_network_conditions的全部参数。
offline
设置为True任何网页都访问不了。
latency
:通过设置延迟增加或减少访问网页速度。

  • 点赞
  • 收藏
  • 分享
  • 文章举报
傻子丶疯子 发布了10 篇原创文章 · 获赞 0 · 访问量 535 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: