This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get core protocols in core, others moved into separate files
- Loading branch information
Showing
6 changed files
with
82 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,45 @@ | ||
(ns clj-webdriver.wait) | ||
(ns clj-webdriver.wait | ||
(:import clj_webdriver.core.Driver | ||
org.openqa.selenium.WebDriver)) | ||
|
||
;;; ## Wait Functionality ## | ||
(defprotocol IWait | ||
"Implicit and explicit waiting" | ||
(implicit-wait [driver timeout] "Specify the amount of time the `driver` should wait when searching for an element if it is not immediately present. This setting holds for the lifetime of the driver across all requests. Units in milliseconds.") | ||
(wait-until | ||
[driver pred] | ||
[driver pred timeout] | ||
[driver pred timeout interval] "Set an explicit wait time `timeout` for a particular condition `pred`. Optionally set an `interval` for testing the given predicate. All units in milliseconds")) | ||
|
||
(extend-type Driver | ||
|
||
IWait | ||
(implicit-wait [driver timeout] | ||
(.implicitlyWait (.. (:webdriver driver) manage timeouts) timeout TimeUnit/MILLISECONDS) | ||
driver) | ||
|
||
(wait-until [driver pred] | ||
(wait-until driver pred 5000 0)) | ||
(wait-until [driver pred timeout] | ||
(wait-until driver pred timeout 0)) | ||
(wait-until [driver pred timeout interval] | ||
(let [wait (WebDriverWait. (:webdriver driver) (/ timeout 1000) interval)] | ||
(.until wait (proxy [ExpectedCondition] [] | ||
(apply [d] (pred d)))) | ||
driver))) | ||
|
||
(extend-type WebDriver | ||
|
||
IWait | ||
(implicit-wait [driver timeout] | ||
(.implicitlyWait (.. driver manage timeouts) timeout TimeUnit/MILLISECONDS) | ||
driver) | ||
|
||
(wait-until | ||
([driver pred] (wait-until driver pred 5000 0)) | ||
([driver pred timeout] (wait-until driver pred timeout 0)) | ||
([driver pred timeout interval] | ||
(let [wait (WebDriverWait. driver (/ timeout 1000) interval)] | ||
(.until wait (proxy [ExpectedCondition] [] | ||
(apply [d] (pred d)))) | ||
driver)))) |