defactosoftware / test_selector Goto Github PK
View Code? Open in Web Editor NEWElixir library to help selecting the right elements in your tests.
License: MIT License
Elixir library to help selecting the right elements in your tests.
License: MIT License
This way we can output/use the helpers in development and test environments, but hide them in production.
Thoughts on this?
We should mention we're also supporting Floki out of the box:
html
|> Floki.find("[test-selector=#{SomeView.test_selector("user")}")
|> Floki.attribute("test-value")
{:safe, selector} = IndexView.test()
Floki.find(html, "[#{selector}]")
And we might want to rename TestSelector.Test.Helpers
to TestSelector.Hound.Helpers
, and optionally add TestSelector.Floki.Helpers
(if any).
This would be nice:
def find_element(:test, view_module, retries \\ 5) do
{:safe, test_selector} = view_module.test()
find_element(:xpath, ~s|//*[@#{test_selector}]|, retries)
end
find_element(:test, MyModule)
But this :(
** (CompileError) lib/test_selector/test_helpers.ex:1: imported Hound.Helpers.Page.find_element/2 conflicts with local function
Since using test_selector can be done without, and is done without using hound, can we move the hound mentions to the Wiki and keep the README clean?
Just like Hound's find_element/3 I'd like to add the retries
option:
def find_test_element(view_module, retries \\ 5)
def search_test_element(view_module, retries \\ 5)
By default Hound retries 5 times. But when I want to make sure a page is lacking an element, I might want to check only once:
assert search_test_element(UserView, "does-not-exist", 1) == {:error, :no_such_element}
Multiple retries significantly increases the testing duration.
Looks like adding an optional attribute will conflict in our function arity, so need to find a workaround.
find_test_element
uses Hound Hound.Helpers.Page.find_element/3
to find a single element.
We should also cover other Hound helpers:
find_all_test_elements
> Hound.Helpers.Page.find_all_elements/3
.find_within_test_element
> Hound.Helpers.Page.find_within_element/4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.