Python: How to fill out form all at once with splinter/Browser?

≡放荡痞女 提交于 2019-12-21 12:37:26

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/43553630/python-how-to-fill-out-form-all-at-once-with-splinter-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!