stevepryde/thirtyfour

Move towards less duplication of code/features with fantoccini

stevepryde opened this issue · 2 comments

It would be nice to evolve this project towards being less of a wrapper of fantoccini and more of an extension of it.
That is, most fantoccini behaviour should be exposed directly via the Deref trait rather than implementing wrapper methods everywhere.
The focus of this project is to add high-level functionality and tools, especially for test automation use-cases.

I'm not yet sure if this is possible while retaining all of the high-level features of thirtyfour (and adding new ones), but I think it's worth investigating.

v0.30.0 will make some progress here. All method names have been updated to match or at least align more closely with fantoccini. The internal config has also been removed (the config was not ideal anyway because it adds state to the WebDriver which could make automated tests brittle).

This potentially opens the door to implement all thirtyfour features as traits for Element and via Deref for Client. However, I'm hesitant to do that because we then lose some features of thirtyfour, such as:

  • Using By instead of Locator. We support more selectors by wrapping some existing ones (could add support to fantoccini? either Into<Locator> or otherwise add the extra selectors to Locator)
  • WebDriverError - actually this is quite similar to CmdError anyway, but we lose the ability to have any additional errors
  • script return value helpers (fantoccini could be updated to make the return value generic over T: DeserializedOwned)

I've decided to leave it mostly as is for now.

Some types will continue to be re-exported from fantoccini, so the dependency will be explicit. This does mean breaking changes of fantoccini will require breaking changes in thirtyfour, but this is unavoidable without essentially rewriting half of fantoccini anyway, which I don't want to do.

Also there are some benefits to wrapping the driver (client) and elements as they are now:

  • Higher-level documentation with examples
  • Additional methods as needed
  • Support for By, ScriptRet etc.
  • Better docs without using async-trait

Some minor (but breaking) changes will be made for v0.31.0. Mostly just refactoring modules and module paths to make it more explicit which things are re-exported etc.