SELENIUM2 provides a driver with no UI mode, that is, Htmlunitdriver. Features run relatively fast. In fact, Htmlunitdriver is the encapsulation of htmlunit, so that everyone can use their own custom selenium2 grammar to use it.
Set up Htmlunitdriver agent and handle user authentication issues
proxy = new Proxy (); Set the proxy server address Proxy.sethttpproxy ("Proxy server address: port number"); Desiredcapabilities capabilities = Desiredcapabilities.htmlunit (); Capabilities.setcapability (Capabilitytype.proxy, PROXY); Webdriver Driver = new Htmlunitdriver (capabilities) {@Override protected WebClient Modifyweb Client (WebClient client) {Defaultcredentialsprovider creds = new Defaultcredentialsprovider (); Creds.addcredentials ("User name", "password"); Client.setcredentialsprovider (creds); return client; } }; Driver.get ("http://www.baidu.com"); System.out.println ("[" + driver.gettitle () + "]");