semperos/clj-webdriver — Issue #42: Decouple by-* generation and element finding for Driver find-element function
Author: semperos
Created: 2012-02-14 20:26:37+00:00
State: open

Currently, the `find-element` (previously `find-it`) function performs a number of checks to eventually produce a `(by-` clause (e.g., `(by-xpath)` or `(by-tag)`). It then uses that by-clause with `find-element-by` to get the actual WebElement objects back and instantiate Element records.

The `find-element` function is in the `IFind` protocol and is implemented against both the `Driver` and the `Element` types. For `Driver`, this is the same behavior as the old `find-it` function; it takes a `Driver` instance and finds an element based on an `attr-val` map. For `Element`, the first parameter is a parent element under which another element should be found, based on the second parameter which is a traditional by-clause.

However, instead of allowing people to use maps in certain places (with the `Driver` variant of `find-element`) and by-clauses elsewhere (with the `Element` variant of `find-element`), we introduce accidental complexity. What is needed is the ability to generate the resultant by-clause that the `Driver` variant of `find-element` produces. That's what needs to be decoupled from the current implementation of `find-element` against the `Driver` type.