Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Adding capabilities protocol work
Browse files Browse the repository at this point in the history
Conflicts:
	test/clj_webdriver/test/remote_existing.clj
  • Loading branch information
Nathan Smith committed Aug 30, 2012
2 parents b216f88 + 2b146d3 commit d11c78c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src/clj_webdriver/remote/driver.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
(ns clj-webdriver.remote.driver
(:use clj-webdriver.capabilities)
term(ns clj-webdriver.remote.driver
(:import [org.openqa.selenium.remote
DesiredCapabilities RemoteWebDriver
HttpCommandExecutor]
DesiredCapabilities
RemoteWebDriver]
clj_webdriver.driver.Driver))

(defprotocol IRemoteWebDriver
Expand All @@ -13,6 +12,19 @@
(session-id [driver] "Get the session id for the given `driver`")
(session-id! [driver new-id] "Set the session id for the given `driver`"))

(defprotocol IDesiredCapabilities
"Way to interact with DesiredCapabilities settings"
(browser-name [driver] "Get browser name of remote `driver`")
(browser-name! [driver new-name] "Set browser name of remote `driver`")
(capability [driver cap-name] "Get capability by name as String of remote `driver`")
(capability! [driver cap-name cap-value] "Given a `k` key and `v` value compatible with any of the arities of `setCapability()`, set the value of the given capability for the given remote `driver`")
(platform [driver] "Get platform of remote `driver`")
(platform! [driver platform-name] "Given the name of a platform as either a keyword or string (case-insensitive), set the platform of the remote `driver` accordingly")
(version [driver] "Get version of remote `driver`")
(version! [driver version-string] "Set the version of the remote `driver`")
(javascript [driver] "Get boolean value if javascript is enabled or not")
(javascript! [driver enabled] "Set boolean value to enable or disable javascript"))

(extend-type Driver
IRemoteWebDriver
(capabilities [driver]
Expand Down Expand Up @@ -61,4 +73,12 @@

(version! [driver new-version]
(let [caps (capabilities driver)]
(.setVersion caps new-version))))
(.setVersion caps new-version)))

(javascript? [driver]
(let [caps (capabilities driver)]
(.isJavascriptEnabled caps)))

(javascript! [driver enabled]
(let [caps (capabilities driver)]
(.setJavascriptEnabled caps enabled))))
1 change: 1 addition & 0 deletions test/clj_webdriver/test/remote_existing.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
(int (get (System/getenv) "WEBDRIVER_HUB_PORT" 3333)))

(declare driver)

;; Fixtures
(defn reset-browser-fixture
[f]
Expand Down

0 comments on commit d11c78c

Please sign in to comment.