How to install selenium on pycharm
The first stage of the process is to make sure you have installed PyCharm IDE. You can download PyCharm here.
Open the download file and follow the setup instructions (leave settings as their default values unless you have a specific reason to do otherwise).
Once done, create a new project if you haven't already.
Installing Selenium on your project
To install Selenium on your python project, follow these steps:
- Open File > Settings > Project from the PyCharm toolbar
- Select the project you want to install Selenium on
- Click the tab "Python Interpreter" within the project tab
- Click the + symbol to add a new library to the project
- Type "Selenium" into the new library search box, select the "Selenium" library and confirm by clicking "install package"
- When the installation has finished, close the project settings window.
Testing the installation
To check that Selenium has been correctly installed into PyCharm, create a new .py file. Next, copy and paste the following code into your file.
from selenium import webdriver driver = webdriver.Chrome() driver.maximize_window() driver.get("https://www.wikipedia.org/") query = driver.find_element("id", "searchInput") query.send_keys("Hello World") query.submit() print(driver.find_element("id", "firstHeading").text) assert driver.title == "\"Hello, World!\" program - Wikipedia" driver.close()
Run this file and check that first, a window is opened and shortly closed, and second, that the output in pycharm contains the text: "Hello, World!" program.
Leave a reply
Your email address will not be published. Required fields are marked*