2014-04-12 98 views

回答

5

對於CLJ-0.6.1的webdriver與PhantomJS支持您可以通過設置能力做到這一點

(ns site-test 
    (:require [clj-webdriver.taxi :refer :all] 
      [clj-webdriver.driver :refer [init-driver]]) 
    (:import (org.openqa.selenium.phantomjs PhantomJSDriver) 
      (org.openqa.selenium.remote DesiredCapabilities))) 

(System/setProperty "phantomjs.binary.path" "D:/Drivers/phantomjs-1.9.7-windows/phantomjs.exe") 

(set-driver! 
    (init-driver 
     {:webdriver 
     (PhantomJSDriver. (doto (DesiredCapabilities.) 
          (.setCapability "phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0") 
          (.setCapability "phantomjs.page.customHeaders.Accept-Language" "en-US") 
          (.setCapability "phantomjs.page.customHeaders.Connection" "keep-alive") 
          (.setCapability "phantomjs.cli.args" (into-array String ["--ignore-ssl-errors=true" 
                        "--webdriver-loglevel=WARN"]))))})) 
相關問題