DEV Community

Pranilesh_Royal
Pranilesh_Royal

Posted on

need help with python automation

hello everyone Im new here,and im looking for a solution to my problem in python automation.IM working on a project where I need to auto fill a online form using python.I have the required data but the problem is how can i do what i want.I just want to fill in the fields using selenium and python then skip the other steps and then use other data from the excel file close the browser and then repeat the process.

I would appreciate your help,earlier I tried it with pyautogui but i wasn't successful.

Top comments (1)

Collapse
 
franga2000 profile image
Miha Frangež • Edited

For most web forms, full browser automation isn't really needed. Usually, one just needs to figure out how the data is formatted and where it's being sent and just do that. I've seen literally 100x speedups over Selenium this way.

Try opening the browser's network inspector (devTools > Network for Firefox, but Chrome probably has the same), filtering it to only show HTML and XHR and checking "preserve log". Submit the form and look for a POST request. You can then simply re-create it in Python (I recommend the Requests library), fill in your data and send it.

EDIT: If there's a CSRF token, just do a GET on the page and pull it out with a RegEx before each POST.