Is there any module or way in python for filling web form without using selenium
-
Is that [google forms](https://www.google.com/forms/about/)? – heittpr Aug 08 '20 at 07:56
-
any type of web forms @heitor – dx4iot Aug 08 '20 at 07:57
-
without selenium @DaveIdito – dx4iot Aug 08 '20 at 07:59
-
Any specific reasons why you are avoiding Selenium? – DaveIdito Aug 08 '20 at 08:00
-
because I need to do this process without opening any browser or selenium driver @DaveIdito – dx4iot Aug 08 '20 at 08:04
-
1Well, there's lots of ways to do it, depending on the website you could use an API (take a look at [this](https://stackoverflow.com/questions/18073971/http-post-to-a-google-form/47444396) for google forms). Or just use the network inspector tool to find out what requests your browser is making and try to mimic them using [requests](https://requests.readthedocs.io/en/master/) for example. But Selenium is a pretty versatile solution since many websites have anti-automation measures and don't work well with plain requests without user-agents. – heittpr Aug 08 '20 at 08:04
-
If the GUI is the problem, take a look at headless mode on [firefox](https://stackoverflow.com/questions/46753393/how-to-make-firefox-headless-programmatically-in-selenium-with-python) or [chrome](https://stackoverflow.com/questions/53657215/running-selenium-with-headless-chrome-webdriver) @dx4iot – heittpr Aug 08 '20 at 08:07
-
@dx4iot any headless browser should do the job then. Here's a [list](https://github.com/dhamaniasad/HeadlessBrowsers). The processes would remain the same nonetheless. – DaveIdito Aug 08 '20 at 08:07
1 Answers
For multiple reasons, logging into sites like Gmail and Facebook using WebDriver is not recommended. Aside from being against the usage terms for these sites (where you risk having the account shut down), it is slow and unreliable.
The ideal practice is to use the APIs that email providers offer, or in the case of Facebook the developer tools service which exposes an API for creating test accounts, friends and so forth. Although using an API might seem like a bit of extra hard work, you will be paid back in speed, reliability, and stability. The API is also unlikely to change, whereas webpages and HTML locators change often and require you to update your test framework.
Logging in to third party sites using WebDriver at any point of your test increases the risk of your test failing because it makes your test longer. A general rule of thumb is that longer tests are more fragile and unreliable.

- 940
- 1
- 7
- 13