Your ultimate guide

Setup Environment for Python with Selenium



Setup & Configure Web Driver in PyCharm:

Pre-Requirements:
1.  Python
2.  PyCharm
3.  Download browser Specific Drivers.

    Step 1:
- Download and install Python.

    Step 2: 
- Download and install PyCharm

    Step 3 :
- To download Browser-specific divers first, go to the official Selenium website.
- Then go to the Download page.

        

- Scroll down the page to search "+Browsers" Button

        


- Click on that "+Browser" button, and then you will see all the browser-specific drivers' links.

        


- Based on which browser you want to do automation testing that related browser driver you need to download.
- Direct links:


Setup Environment: 
    Step 1: First we need to create Project
- Open "PyCharm"
- Click on the Menu (☰),  Select File in that click on New Project...

        

- or, If you open PyCharm for the First time we will see like this, Here click on New Project. 

        

- Specify the Project name and its location, then click on Create

        

- Then your project will be created.

        


    Step 2: Installing Selenium
        We can install selenium in different ways:
        1) Through GUI
                a) Click on the Menu (☰),  Select File in that click on Settings... (shortcut: Ctrl+Alt+S)
                
                b) Select your Project ("Project: YourProject"), then click on Python Interpreter
                
                c) Click on the "+" button
                
                d) Search for "selenium", then click on Install Package.
                    Note: By default, it installs the latest version. If you want to install the older version of Selenium click on '☑Specify Version' and choose the version in the dropdown list. (If the latest version of Selenium causes the error, install an earlier version of Selenium)

                
                e) Then selenium will be installed in your project.
                


        2) Through Terminal (CLI)
                a) On PyChram, left downside we will see the Terminal symbol, click on that (shortcut: Alt+F12)
                
                b) Terminal, shows the current project location(path), there enter this command "pip install selenium" and then press ENTER. Then it will install latest the version of Selenium in your project. 
                Note: If you want to install an older version for example 'selenium 4.91' the command will be like this: pip install selenium==4.9.1

                
                c) Then it will download the selenium driver to your project.


    Step 3: Browser-Specific Drivers
        1) After downloading browser web drivers, by default the files are in .zip format.
        2) First we need to unzip(Extrat) that file, and then all the extracted files need to store in a separate Folder. So that we can find them easily.

(For example, create a folder with the name 'drivers' in C-drive, and move all the extracted web driver files to this folder)

        


No comments:

Post a Comment