This script demonstrates how to use Selenium to automate form filling and submission on a web page. It uses the SeleniumWire library to intercept and inspect network requests and responses.
The script performs the following steps:
- Opens a Chrome browser using the Chrome WebDriver.
- Navigates to a local web page.
- Finds the email and password fields on the page and fills them with test values.
- Submits the login form.
- Inspects the network requests and prints the response message if it contains a specific pattern.
- Waits for the page URL to change.
- Finds a text field on the page and fills it with a test message.
- Submits the form again.
- Inspects the network requests and prints the response message if it contains a specific pattern.
- Quits the browser.
Note: This script assumes that the Chrome WebDriver is installed and the web page being accessed is running locally.
-
Clone this repository and install all needed dependencies:
cd path/to/repository npm i pip install -r requirements.txt
-
Run the Node.js server:
npm start
-
Open the
index.html
with some similar tool like Live Server on VS Code. -
Make sure that the port of the localhost is 5500.
-
Run the Python script:
python autofill.py