Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium: How to intercept request

Some body know how to intercept/get request url (XHR) and response in Selenium WebDriver? Is it possible?

like image 271
ajile Avatar asked Jul 09 '12 08:07

ajile


1 Answers

Its not directly supported by webdriver, but you can capture all traffic by redirecting it through a proxy. In 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);
like image 85
vidit Avatar answered Nov 11 '22 17:11

vidit