How to Install Selenium Python on IntelliJ (Windows, PyTest)
1. Downloading and Setting up Pip and Python
Click here to download python
Click to open the installer and choose Custom Installation.
Leave the boxes checked in the "Optional Features" section and click Next.
In the "Advanced Options" section, check Add Python to environment variables. Also, click Browse and choose a suitable location for your python files to be installed into. Once, finished click Install.
Note: It is recommended to create the containing folder in this location as each of the installed files and folders will be unpacked here.
Close the window once the installation is complete
2. Installing Intellij IDE
Click here and click Download under "community".
Open the downloaded exe and follow the installation instructions. On the second page in the installation process, you will be asked where to store Intellij.
In the next page you can choose whether to create a shortcut (this is your decision to make). Leave all other boxes unselected and click Next >.
In the next screen click Install to begin installing Intellij.
When the installation is complete, check the box next to "Run IntelliJ IDEA Community Edition" and then click Finish.
For the first time launch, you will have to accept a terms and conditions before continuing.
In the intellij window click New Project.
In the "New Project" window, choose a name and location for your project. Then click the + icon and click Python in the dropdown menu.
Click the Install button next to "Python Community Edition" in the opened window. Then click OK to confirm.
In the project settings window, click Create to confirm the creation of the project.
3. Downloading Chromedriver
Click here to download the chromedriver that matches the version of chrome on your PC. To check the version of chrome you have installed, click the three small dots in the top-right of the Chrome window, then click Help > About Google Chrome.
Create a folder somewhere and store Chromedriver.exe there, note down the location for later.
4. Installing PyTest and Selenium on Intellij
In the IntelliJ window, click File > Project Structure.
In the "Project Structure" window, click on SDKs and then click Packages. Finally, click the + icon.
In the "Available Packages" window, search for "pytest", select it and click Install Package.
Search for "selenium", select it and click Install Package.Once IntelliJ has finished installing the package, close the "Available Packages" window.
Close the "Project Structure" Window.
Right-click your project and click New > Python Package.
Provide the package with a name and press ENTER.
Right-click the package you just created and click New > Python File.
5. Testing the Selenium Setup
In the Python File you created in Section 4, copy in the following code. Replace FILEPATH with the path to the Chromedriver file.
from selenium import webdriver driver = webdriver.Chrome(executable_path="FILEPATH") driver.get("https://www.google.com") print(driver.title) driver.close()
Right-click the script and click Run 'TEST' where TEST is the name of your test file. If the setup was successful, you should see a Chrome window open and close briefly. After the Chrome window has closed, you should see "Google" and "Process finished with exit code 0" printed to the console.
Getting errors you can't seem to fix
If you received errors during this process and can't find an easy fix anywhere, you might be considering shortcuts to finish the process. If you just want to get to a point where you can start writing your own selenium code right away, use MaxTAF Cloud.
You won't receive any errors while setting up MaxTAF Cloud because it is all already set up for you. All you need is a valid email address, and you can start writing test cases for free. The only costs occur when you feel like you need advanced features, like running many tests in parallel, or an extended storage space for test reports and cases.
Leave a reply
Your email address will not be published. Required fields are marked*