4

There was a similar question to this a year ago (Network throttling with chrome and selenium), but it looks like the answers to that question are no longer valid as a bug and fix have come out in the last couple months. https://bugs.chromium.org/p/chromedriver/issues/detail?id=984

I am trying to implement network throttling in google chrome using selenium implemented with Java with little to no success. I'm using the latest chrome driver and standalone server 3.0.1.

Any and all help is greatly appreciated!!

A.E.
  • 56
  • 2
  • 8

2 Answers2

0

You can use proxyServer instead of chrome network throttling.

ProxyServer proxy = new ProxyServer(4444);
proxy.setReadBandwidthLimit(125000); // 125 000 (1Mbps)
proxy.setWriteBandwidthLimit(125000);
cyildirim
  • 614
  • 1
  • 8
  • 20
  • I tried using "ProxyServer" and there was no import automatically detected, so I googled it as well and got nowhere. So where is "ProxyServer" imported from? Or is there a library that needs to be imported to use it? – A.E. Nov 21 '16 at 16:31
  • You can use : ` net.lightbody.bmp browsermob-core 2.1.0-beta-3 test ` – cyildirim Nov 21 '16 at 20:31
  • 1
    The last comment could be confusing to inexperienced users, so to clarify, @cyildirim was saying to use browsermob proxy as a round-about way to limit the bandwidth. It also has many dependencies, so trying to implement it without using maven is very difficult. I would prefer utilizing a direct method of adjusting the network throttling as I find that to be more reliable. I also am interacting with some other proxies already so adding another proxy could make things more complicated. – A.E. Nov 28 '16 at 18:07
0

See my answer in the linked question. Unfortunately Java bindings are not available at the moment, but there is an issue asking to add them, which you can upvote.

Also contributing an implementation should be pretty straight-forward judging from existing bindings for JavaScript and Python.

Yaroslav Admin
  • 13,880
  • 6
  • 63
  • 83