Python:如何使用splinter/Browser一次填写表单?

Dan*_* Me 6 python browser python-2.7 splinter

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

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

但表格依次填写表格,一个接一个.有没有办法一次填写表格?

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

Hak*_*kro 4

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

它接受一个 dict 参数,其中包含字段名称和值,并立即填充表单。

所以你会使用browser.fill_form(dict)而不是browser.fill(field, value)

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

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