Reputation: 91
I need to add some text into the text field that already contains text. When I use fill_in or set functions - it clears previously entered text. So how to add text into text box without clearing previously entered data in it?
Upvotes: 0
Views: 1815
Reputation: 49890
Since you're using Selenium you can do
fill_in('whatever', with: 'text to append', fill_options: {clear: :none})
or
field.set('whatever', clear: :none)
Upvotes: 1
Reputation: 16793
Try using Capybara::Node::Element#send_keys
on your field in question to append more text to it. For example:
find('#your-text-field').send_keys("this is more text to add")
Upvotes: 0
Reputation: 2045
field = find_field 'Text field'
field.set("#{field.value} and something more...")
Upvotes: 1