我正在使用clojure和clj-webdriver一样:
(set-driver! {:browser :phantomjs} "url")
如何设置useragent?
答案 0 :(得分:5)
对于支持PhantomJS的clj-webdriver 0.6.1,您可以通过设置功能
来完成此操作(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"]))))}))