How to install selenium on pycharm

How to install selenium on pycharm

Installing 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:

  1. Open File > Settings > Project from the PyCharm toolbar

  2. Select the project you want to install Selenium on

  3. Click the tab "Python Interpreter" within the project tab

  4. Click the + symbol to add a new library to the project

  5. Type "Selenium" into the new library search box, select the "Selenium" library and confirm by clicking "install package"

  6. 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()
query = driver.find_element("id", "searchInput")
query.send_keys("Hello World")
print(driver.find_element("id", "firstHeading").text)
assert driver.title == "\"Hello, World!\" program - Wikipedia"

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*

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.