Currently, I’m filling out the form on a site with the following:
browser.fill(‘form[firstname]’, ‘Mabel’)
browser.fill(‘form[email]’, ‘[email protected]’)
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!
Get the id tag of each field that you want to automatically fill in using the JavaScript script that the Python script is going to generate, by Inspecting the HTML element of each corresponding field of the online form (s). 2 .
If your online form has fields that are selectable fields (with a drop-down menu) then get the id tags of each of these fields and add them to a .ini (text) file. Save this file with the same name as you will use for your Python script.
There are Python libraries and tools for automatizing browser actions. StackOverflow.com is not a place to ask for an recommendation for such a tool and thus moderators will close this question (SO is usually asking a help for particular problem, not for broad help and tutoriing requests).
With the code pasted, just press enter (with the focus inside the Console tab). Then the online form will be automatically filled in, with the same data contained within the PDF form document. We can check that the data filled into the online form is indeed the same as the one on the PDF form document.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With