Python:如何用splinter/Browser一次填完表格?

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

目前,我正在使用以下内容在网站上填写表格:

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

但是表格是按顺序填写的,一个接一个。有没有一次性填完表格的方法?

谢谢您,一定会投票并接受答案!

浏览器有一个方法叫做:fill_form(field_values)

它接受一个带有字段名称和值的字典参数,并立即填充表单。

因此您将使用 browser.fill_form(dict) 而不是 browser.fill(field, value)

有关浏览器 API 及其方法的更多信息,请点击此处:

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