1

Recently I found that elements found using 'find' of capybara may not work properly with 'fill_in'( Refer:Capybara can find but not fill_in)

So the params used by fill_in and find are different. Hence I can use set and fill my form fields found using 'find' is what I have observed.

Is there any other difference?

Community
  • 1
  • 1
Aks..
  • 1,343
  • 1
  • 20
  • 42

1 Answers1

4

In terms of actually inputting the field, set and fill_in are exactly the same.

The method definition for fill_in is:

def fill_in(locator, options={})
  raise "Must pass a hash containing 'with'" if not options.is_a?(Hash) or not options.has_key?(:with)
  with = options.delete(:with)
  fill_options = options.delete(:fill_options)
  find(:fillable_field, locator, options).set(with, fill_options)
end

As you can see on the last line, the fill_in method is doing the same thing - ie using find to get the node and then inputting it with set.

Justin Ko
  • 46,526
  • 5
  • 91
  • 101