Selenium-rc:如何在 python 中使用 CaptureNetworkTraffic

发布于 2024-09-19 00:20:54 字数 175 浏览 2 评论 0原文

我发现了很多关于java中selenium的教程,其中您首先使用s.start("captureNetworkTraffic=True")启动selenium,但在python中start()没有接受任何论点。

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

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

How do you pass this argument? Or don't you need it in python?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雪花飘飘的天空 2024-09-26 00:20:54

我改变了 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)

你所做的:

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

它就像一个魅力

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

野侃 2024-09-26 00:20:54

以“代理注入模式”启动浏览器(注意 *pifirefox 而不是 *firefox)。然后您可以调用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“技巧”

Start the browser in "proxy-injection mode" (note *pifirefox instead of *firefox). Then you can call the captureNetworkTraffic method.

import selenium
import time

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

I learned the *pifirefox "trick" here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文