如何在python中使用CaptureNetworkTraffic

2024-10-01 11:32:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我在java中找到了许多关于selenium的教程,其中首先使用s.start("captureNetworkTraffic=True")启动selenium,但是在python中start()不接受任何参数。在

你如何通过这个论点?或者你不需要在python中使用它吗?在


Tags: true参数selenium教程javastart论点capturenetworktraffic
2条回答

以“代理注入模式”启动浏览器(注意*pifirefox而不是{})。然后可以调用captureNetworkTraffic方法。在

import selenium
import time

sel=selenium.selenium("localhost",4444,"*pifirefox","http://www.google.com/webhp") 
sel.start()
time.sleep(1)
print(sel.captureNetworkTraffic('json'))

我学会了*pifirefox“技巧”here。在

我在selenium.py中更改了start

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

你所做的:

^{pr2}$

它就像一个符咒

相关问题 更多 >