Selenium-rc: How do you use CaptureNetworkTraffic in python

前端 未结 2 1303
失恋的感觉
失恋的感觉 2021-02-15 16:52

I\'ve found many tutorials for selenium in java in which you first start selenium using s.start(\"captureNetworkTraffic=True\"), but in python start()

2条回答
  •  名媛妹妹
    2021-02-15 17:19

    I changed the start in selenium.py:

    def start(self, captureNetworkTraffic=False):
        l = [self.browserStartCommand, self.browserURL, self.extensionJs]
        if captureNetworkTraffic:
            l.append("captureNetworkTraffic=true")
        result = self.get_string("getNewBrowserSession", l)
    

    The you do:

    sel = selenium.selenium('localhost', 4444, '*firefox', 'http://www.google.com')
    sel.start(True)
    sel.open('')
    print sel.captureNetworkTraffic('json')
    

    and it works like a charm

提交回复
热议问题