简体   繁体   中英

Selenium: How to intercept request

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

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM