Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Remote DesiredCapabilites #69

Closed
wants to merge 3 commits into from

1 participant

@smidas

Added functionality for the browser spec passed to new-remote-session function in the remote namespace to accept a key (:capabilities) that can take a DesiredCapabilities instance and pass it to the RemoteWebDriver. If you don't provide this key, new-remote-session will use previous mechanism for creating a RemoteWebDriver.

Included a simple test as well.

Nathan Smith added some commits
@smidas smidas closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 25, 2012
  1. Added specified remote capabilites testing

    Nathan Smith authored
  2. Browser spec can now contain :capabilities key handling custom capabi…

    Nathan Smith authored
    …lities passed to the RemoteWebDriver constructor.
  3. Added let block to address function to reduce the need to call get-in…

    Nathan Smith authored
    … on remote-server.
This page is out of date. Refresh to see the latest.
View
40 src/clj_webdriver/remote/server.clj
@@ -47,32 +47,38 @@
(start remote-server))))
(address [remote-server]
- (str "http://"
- (get-in remote-server [:connection-params :host])
- ":"
- (get-in remote-server [:connection-params :port])
- (apply str (drop-last (get-in remote-server [:connection-params :path-spec])))
- (when (get-in remote-server [:connection-params :existing])
- "hub")))
+ (let [{:keys [host port path-spec existing]} (:connection-params remote-server)]
+ (str "http://"
+ host
+ ":"
+ port
+ (apply str (drop-last path-spec))
+ (when existing
+ "hub"))))
(new-remote-webdriver*
[remote-server browser-spec]
(let [wd-url (address remote-server)
- {:keys [browser profile] :or {browser :firefox
- profile nil}} browser-spec]
- (if-not profile
- (RemoteWebDriver. (HttpCommandExecutor. (as-url wd-url))
- (call-method DesiredCapabilities browser nil nil))
- (throw (IllegalArgumentException. "RemoteWebDriver instances do not support custom profiles.")))))
+ {:keys [browser profile capabilities] :or {browser :firefox
+ profile nil
+ capabilities nil}} browser-spec]
+ (cond
+ profile (throw (IllegalArgumentException. "RemoteWebDriver instances do not support custom profiles."))
+ capabilities (RemoteWebDriver. (HttpCommandExecutor. (as-url wd-url))
+ capabilities)
+ :else (RemoteWebDriver. (HttpCommandExecutor. (as-url wd-url))
+ (call-method DesiredCapabilities browser nil nil)))))
(new-remote-driver
[remote-server browser-spec]
- (let [{:keys [browser profile cache-spec] :or {browser :firefox
- profile nil
- cache-spec {}}} browser-spec]
+ (let [{:keys [browser profile capabilities cache-spec] :or {browser :firefox
+ profile nil
+ capabilities nil
+ cache-spec {}}} browser-spec]
(init-driver {:webdriver (new-remote-webdriver* remote-server
{:browser browser
- :profile profile})
+ :profile profile
+ :capabilities capabilities})
:cache-spec cache-spec})))
(start-remote-driver
View
17 test/clj_webdriver/test/remote_existing.clj
@@ -7,7 +7,9 @@
[clj-webdriver.test.common :only [run-common-tests]]
[clj-webdriver.remote.server :only [new-remote-session stop]])
(:require
- [clj-webdriver.remote.driver :as rd]))
+ [clj-webdriver.remote.driver :as rd])
+ (:import
+ [org.openqa.selenium.remote.DesiredCapabilities]))
;; Utilities
(defn hub-host
@@ -27,6 +29,16 @@
(def server this-server)
(def driver this-driver))
+;; Testing with specified DesiredCapabilities
+(let [capabilities (DesiredCapabilities/firefox)
+ [this-server this-driver] (new-remote-session {:port (hub-port)
+ :host (hub-host)
+ :existing true}
+ {:browser :firefox
+ :capabilities capabilities})]
+ (def cap-server this-server)
+ (def cap-driver this-driver))
+
;; Fixtures
(defn reset-browser-fixture
[f]
@@ -43,4 +55,5 @@
;; RUN TESTS HERE
(deftest test-suite-with-remote-driver-attached-to-manually-started
- (run-common-tests driver))
+ (run-common-tests driver)
+ (run-common-tests cap-driver))
Something went wrong with that request. Please try again.