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

Support time inputs #245

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Antsiscool
Copy link

I am converting a project over from capybara selenium and found that time inputs were failing to be correctly set.

This allows specifying the time as a string or a Time object. The date attributes will be ignored.

I have added test cases for both string and time. I also added some test cases for date inputs as well.

@Antsiscool
Copy link
Author

I am not sure why the tests are failing. They are all failing for me locally on the main branch as well.

@brodienguyen
Copy link

I am interested in following up this contribution as well.

@route Not sure if you are the project's maintainer, but could you give us some insights if you know why all the tests are falling please?

@Antsiscool
Copy link
Author

I have just rebased my changes onto the latest main branch.

@route
Copy link
Member

route commented Jan 5, 2024

Just approved them to run

@route
Copy link
Member

route commented Jan 7, 2024

Weird, dunno let me release new Ferrum and push my changes to cuprite and I'll get this into new release

Comment on lines +106 to +108
when "time"
value = value.strftime("%H:%M") if value.is_a?(Time)
node.evaluate("this.setAttribute('value', '#{value}')")
Copy link

@Slotos Slotos Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest changing lib/capybara/cuprite/javascripts/index.js to:

    } else if (node.type == "time") {
      this.setValue(node, value);
      this.input(node);
Suggested change
when "time"
value = value.strftime("%H:%M") if value.is_a?(Time)
node.evaluate("this.setAttribute('value', '#{value}')")
when "time"
value = value.strftime("%H:%M") if value.is_a?(Time)
command(:set, value.to_s)

This way, input event will be emitted correctly and value attribute won't be modified unnecessarily.

@janwerkhoven
Copy link

Need this. +1 👀

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

Successfully merging this pull request may close these issues.

5 participants