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

Include input values in the result of Floki.text/2 #391

Closed
stefanchrobot opened this issue Mar 15, 2022 · 4 comments · Fixed by #459
Closed

Include input values in the result of Floki.text/2 #391

stefanchrobot opened this issue Mar 15, 2022 · 4 comments · Fixed by #459
Labels

Comments

@stefanchrobot
Copy link

Feature goal

Include the values of <input ...> elements in Floki.text/2.

This would be helpful for making assertions on pages that have edit forms:

test "the form is prefilled with the current entity" do
  # ...
  text = Floki.text(html)

  assert text =~ "current value"
end

This could be implemented as an option for Floki.text/2:

Floki.text(html, inputs: true)

or

Floki.text(html, inputs: ["text"])
@philss
Copy link
Owner

philss commented Mar 15, 2022

This would be a nice feature!

I think inputs: true is better. Since we need to consider the select and radio tags, maybe form_values: true could be a better name. WDYT?

A PR is welcome :)
Please let me know if you need guidance here.

@stefanchrobot
Copy link
Author

Cool, let me write some more tests that need checkboxes and radios and I'll come back with a PR. form_values: true sounds best.

@Benjamin-Philip
Copy link
Contributor

Can I work on this?

@stefanchrobot
Copy link
Author

Sure, feel free to do so! I wasn't able to find time to get back to this. Some comments:

  • Checkboxes and radios don't really need this, since with Floki.text I'd be more interested in the <label> element than the value of <input>,
  • Consider adding support (now or in the future) for the ARIA attributes (not only forms, but any element).

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

Successfully merging a pull request may close this issue.

3 participants