6

Currently, I’m filling out the form on a site with the following:

browser.fill(‘form[firstname]’, ‘Mabel’)
browser.fill(‘form[email]’, ‘hi@hi.com’)
browser.select(‘form[color]’, ‘yellow’)

But the form gets filled out the form sequentially, one after the other. Is there a way to fill out the form all at once?

Thank you and will be sure to vote up and accept the answer!

DSM
  • 342,061
  • 65
  • 592
  • 494
Dan Me
  • 2,143
  • 4
  • 19
  • 19

1 Answers1

4

Browser has a method called: fill_form(field_values)

It takes a dict parameter, with the field names, and the values, and it fills the form at once.

So you'll use browser.fill_form(dict) instead of browser.fill(field, value)

More info about Browser's API and its methods here :

https://splinter.readthedocs.io/en/latest/api/driver-and-element-api.html

Hakro
  • 2,625
  • 1
  • 12
  • 23
  • 1
    don't think I'm quiet understanding how it works. Do you mind showing a small example? – Dan Me Apr 24 '17 at 16:46
  • 1
    and how can I apply to `.select()` as well? – Dan Me Apr 24 '17 at 17:21
  • appreciate it! But I can still see that it is being filled out 1 at a time, then all at once. Is there a way to fill out the form all at once? Here is the dict I'm using: `form_dict = { ’form[firstname]’: ‘Mabel’, ‘form[email]’: ‘hi@hi.com’, ‘form[color]’: ‘yellow’ }` – Dan Me Apr 24 '17 at 23:41
  • According to the doc, fill_form() supports the following fields: text, password, textarea, checkbox, radio and select. If your fields are named form[firstname], form[email] and form[color], it should work just by using browser.fill_form(from_dict) I don't think there is an other way to do it "all at once" – Hakro Apr 25 '17 at 12:40
  • Thank you. Appreciate your answer! – Dan Me Apr 26 '17 at 22:29