In this guide, you’ll learn how to set up Selenium with Python from scratch and run your first test script.
- Python Installation
- Get a Python version that is appropriate for your operating system.https://www.python.org/downloads/
- In the process of installation, be sure to select “Add Python to PATH.”
- Test your setup:
* Open a terminal.
* Execute python –version or python3 –version.
How to Install Selenium for Python
The Selenium package from PyPI is installed using pip when you are configuring Selenium for Python. This makes it simple to incorporate Selenium into your Python environment and begin automating web browsers.
Installing using pip
You must make sure that pip is installed before you can use it to install Selenium. Here’s the process of how to install pip.
On windows:
- Download theget-pip.py Script:
https://bootstrap.pypa.io/get-pip.py - On your device, save the file.
- Next, open a command prompt and navigate to the directory where the get-pip.py script is located.
- To install pip, run the command below:
python get-pip.py
Verifying pip Installation
Once the script has run, perform the following to confirm pip is installed:
Pip –version
pip most recent version will be displayed.
On macOS:
- Launch a terminal.
- To install pip, run the command below:
After installing pip, you can install Selenium Python:
- Get the terminal or command prompt open
- To install Selenium, use the command below:
pip install selenium
driving the need for qualified personnel. The roles in automation and quality assurance span from junior testers to senior roles.
Programming and framework knowledge are technical abilities that are essential for Selenium testing success. Testers can secure their future by keeping abreast of developments in DevOps andVerifying Selenium Installation
To confirm that Selenium is installed correctly, open a Python shell by typing python in your terminal or command prompt. Then, run:
importselenium
print(selenium.__version__)
If you see the version number without errors, the installation was successful.
And that’s it! Now, pip is being used to set up Selenium. In your Python applications, you can start using Selenium to automate and test the web.
Setting Up Web Drivers
A web driver is necessary for Selenium to communicate with browsers. Browsers and Selenium programs communicate via web drivers.
Select a driver based on which browser you wish to automate:
Chrome: Use ChromeDriver.
Firefox: Use GeckoDriver.
Edge: Use EdgeDriver.
Make sure the version of the driver and your browser are the same. You can now develop your Selenium test script.