Selenium:如何拦截请求

时间:2012-07-09 08:00:39

标签: c# selenium webdriver

有些团体知道如何在Selenium WebDriver中拦截/获取请求网址(XHR)和响应?有可能吗?

1 个答案:

答案 0 :(得分:1)

它不受webdriver直接支持,但您可以通过代理重定向来捕获所有流量。在java ..

Proxy proxy = new Proxy();
// This should be the address of proxy.
proxy.setHttpProxy("localhost:8080");

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.PROXY, proxy);

WebDriver driver = new FirefoxDriver(capabilities);