Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create custom strategy types? #171

Open
sn3p opened this issue Jul 20, 2017 · 1 comment
Open

Create custom strategy types? #171

sn3p opened this issue Jul 20, 2017 · 1 comment

Comments

@sn3p
Copy link

sn3p commented Jul 20, 2017

We just released the first version of test_selector, a set of helpers to set/get test selectors to/from elements in a Phoenix app (when env == :test). These selectors are hashed (scoped to the view module they are used in) for accurate selection and "leakage" prevention. See our Wiki for examples. The reason we created this is we prefer reserving classes for styling, and id's have limitations because they have to be unique.

My question:

Our test helpers currently use find_element(:xpath, ..., but is there a way to create a custom strategy type? For example:

find_element(:test, "user", user.id)

I tried:

def find_element(:test, view_module, retries \\ 5) do
  {:safe, test_selector} = view_module.test()
  find_element(:xpath, ~s|//*[@#{test_selector}]|, retries)
end

But this results in an error:

** (CompileError) lib/test_selector/test_helpers.ex:1: imported Hound.Helpers.Page.find_element/2 conflicts with local function

@danhper
Copy link
Collaborator

danhper commented Sep 6, 2017

Hi, thanks for the proposal and sorry for the delay.
I agree custom strategies could be helpful, but I do not have time to take care of it right now. If you would like to try implementing it, please feel free to send a PR.
Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants