Search code examples
pythonseleniumbrowsermob

How to run Multiple Servers in BrowserMob Selenium and Python


Hi all I want to run multiple browsermob servers in python(want to detect http of two chrome browsers simultaneously but in a way that it can be separated later), however when I assign second server to second proxy I get the error 'No json object could be decoded'

My code is following

server1 = Server(path_browsermobproxy, options={'port':9090})
server1.start()
proxy1 = server1.create_proxy()



profile1 = webdriver.FirefoxProfile()
profile1.set_proxy(proxy1.selenium_proxy())


server2 = Server(path_browsermobproxy, options={'port':9091})
server2.start()
proxy2 = server2.create_proxy()

profile2 = webdriver.FirefoxProfile()
profile2.set_proxy(proxy2.selenium_proxy())

Solution

  • download the latest version

    https://github.com/automatedtester/browsermob-proxy-py

    then pass a new proxy port create_proxy({"port":9911})

    browsermobproxy will always try to use the port 8081 the the second instance will silently crash