SELENIUM BASICS:

  • What is Automation Testing - Advantages & Types of Tools
  • What is Selenium IDE, Selenium RC, Selenium WebDriver, Selenium Grid?
  • Selenium IDE, Firebug & Firepath Installation

  • SELENIUM WEBDRIVER:

  • Selenium WebDriver Architecture
  • Selenium Installation
  • Challenges and Limitations of Selenium
  • First Selenium WebDriver Script
  • Working with Firefox Browser
  • Solution - Failed To Launch Browser Using Selenium WebDriver
  • Working with Chrome Browser
  • Working with IE Browser
  • Difference Between FindElement & FindElements
  • Install Firebug, Fire path and other add on for Selenium
  • Locators in Selenium
  • Dynamic Xpath
  • Dynamic CSS
  • Handle drop-downs
  • How to work with file upload
  • Handle Alerts & Popups
  • Handle Multiple Windows
  • Mouse Hover event in Selenium
  • Right Click
  • Double Click
  • Drag and Drop
  • Capture Screenshots in Selenium
  • Parameterization
  • Synchronization
  • Implicit Wait, Explicit Wait and Fluent Wait in Selenium
  • Implicit Waits
  • Explicit WebDriver Waits
  • Fluent Wait In Selenium
  • Apache POI
  • How To Read Data From Excel File
  • How To Write Data In Excel File
  • Database Testing Using MSSQL
  • Database Testing Using MySQL
  • Database Testing Using DB2
  • Handle Ajax Call in Selenium
  • Listeners in Selenium
  • Handling JavaScript in Selenium
  • Stale Element Reference Exception in Selenium
  • Integrate Sikuli with Selenium
  • Headless Browser Testing 
  • Headless Browser Testing using HtmlUnitDriver
  • Headless Browser Testing using PhanthomJSDriver

  • TESTNG:

  • TestNG Installation
  • TestNG Complete Tutorial

  • REPORTS:

  • Extent Reports Introduction
  • Extent Reports Generation
  • Capturing Screenshots & Including In Extent Reports
  • Extent Reports Version 4

  • BUILD & CONTINUOUS INTEGRATION TOOLS:

  • ANT Build Tool - How To Download & Install
  • Maven Build Tool - How To Download & Install
  • Creating Maven Selenium Project
  • GIT Integration with Selenium
  • Jenkins - How To Download & Install
  • Jenkins - Executing TestNG Scripts
  • Jenkins - Generating Reports After Test Execution
  • Jenkins - Executing Maven Project
  • Create build and Execute build for nightly execution
  • Send Email report based on build Status
  • Selenium Continuous Integration with Jenkins [Selenium – Maven – Git – Jenkins] – Step By Step Guide

  • CROSS BROWSER TESTING:

  • Running Selenium Tests On BrowserStack
  • Kobiton - Mobile Testing Platform with Real Devices

  • MOBILE TESTING:

  • Mobile Testing Platform with Real Devices

  • AUTOMATION FRAMEWORKS:

  • What is Framework & Types of Framework
  • Page Object Model Design Pattern
  • Data Driven Framework
  • How to explain Test Automation Framework or Selenium Automation Framework Architecture In Interview

  • API Testing:

  • Learn API Testing
  • Postman Tutorial (API Testing with Postman)

  • INTERVIEW QUESTIONS:

  • Test Automation Framework Interview Questions
  • Selenium Interview Questions
  • TestNG Interview Questions
  • Java Interview Questions
  • Python Interview Questions
  • API Testing Interview Questions

  • SAMPLE RESUME:

  • Automation Tester Resume
  • Selenium Python Tutorial For Beginners

    Selenium Python Tutorial

    Earlier we have learned Selenium using Java and in this post, we will learn Selenium Python. Most of the companies looking for automation testers who have knowledge in Selenium WebDriver using Python.

    In this Selenium Python tutorial, you will learn the following

    I hope at the end of this tutorial, you will be able to write and execute Selenium test scripts using Python Programming language in different web browsers.

    Most newcomers to automation testing ask me this question “Why choose Python over Java in Selenium”. Selenium with Java is popular in the market but to say in favor of Python Webdriver over Java are.

    1. Learning Python is easy compared to Java.
    2. Python codes are shorter compared to Java.
    3. Python is more productive compared to Java because codes can be written in fewer lines.

    How To Install Python:

    Let’s see the installation of Python.

    The following steps need to be followed for the configuring Python and Selenium in our machine:

    Step 1: The python.exe file has to be obtained from the official site: 

    https://www.python.org/downloads/

    Python Download

    Then click on the Download Python button. The python executable file gets downloaded with its latest version. If we are looking for a specific python version, then that will also be available on their official website.

    Release Versions

    If we are on other operating systems like Linux / UNIX, MAC, and so on, we should click on that specific link and the corresponding page should be navigated. For example for Linux / UNIX user, we are redirected to that specific page:

    Latest Source Release

    Step 2: Once the .exe file gets downloaded, we need to proceed with the next steps until the installation is completed. Then we can move to the location where the python got installed and check it.

    Generally the path:

    Step 3: For the Windows users only, we have to set the path of System Environmental variables. Here we have to add the location of the Python folder [path where it got installed in our local system]. Also, there will be a Scripts folder inside the main Python folder. We have to set that path as well in System Environmental variables.

    Step 4: To verify that Python has been successfully installed, we need to run the command: python –version

    Python Version Command Line

    In case, the proper installation has not happened, error messages shall be displayed.

    Step 5: Next we have to install Selenium bindings in our system. This will be achieved with the help of PIP Python has a package manager which helps to install and configure the required packages which are not included in the Python library.

    Step 6: We will visit the site: https://pypi.org/project/selenium/ for getting all the necessary resources for setting up Selenium with Python in our system.

    pip Install Selenium

    Step 7: As suggested by the official web site of Python, we need to run the command pip install selenium from the command prompt. We can now find a selenium folder created inside the Python folder. [Python ->Lib ->site-packages].

    Step 8: If we want to upgrade the present version of the package, we need to run the command pip install -U selenium from the command prompt. To confirm if Selenium has installed successfully, we need to run the command pip show Selenium. If there are multiple versions of Python in our system, we need to run the command pip3 show Selenium. This will display all the information like version, location and so on.

    Verify Selenium Version

    Step 9: Finally we shall download the PyCharm editor [developed by JetBrain] in our system to code for our automation. The link to download from is :

    https://www.jetbrains.com/pycharm/download/#section=windows

    There are both licensed [Professional] and free [Community] versions of PyCharm available. For our testing purpose, the Community version is sufficient.

    Step 10: After installation of PyCharm, we need to create a new project from File -> New Project -> <<Provide the name of project>>. Then click on the Create While creating the project we shall select Virtualenv for the New Environment Using field. Also, we have to select a Basic interpreter. Here we should select the latest Python interpreter available in our system.

    Next, we have to create a new Python package by selecting the Project that we created and finally a Python file inside the package.

    To verify if the Selenium packages are available in our project, let’s open the External Libraries folder. Then if we move to the site-packages folder, we shall find selenium libraries are added. The other Python libraries shall also be present there.

    External Libraries Path

    How to run tests in various browsers in Selenium Python?

    Selenium allows a wide range of browsers like Chrome, Firefox, Internet Explorer, and Safari, and so on for automation testing. For testing any application, we need to open a browser explicitly as Selenium does not have the ability to continue working on the already opened browser.

    For running tests in the Chrome browser, we need to download the chromdriver.exe file from https://www.selenium.dev/ and save it on a location. In Python, we have to import the WebDriver library to our code with help from selenium import webdriver statement to launch the Chrome browser.

    Then we have to create a driver instance. It shall contain the webdriver.Chrome () where we have to specify the location of the chromedriver.exe file. This is done by setting up the executable_path property to the Chrome class constructor.

    Code Implementation to launch the Chrome browser.

    For running tests in the Firefox browser, we need to download the geckodriver.exe file from https://www.selenium.dev/ and save it on a location. In Python, we have to import the WebDriver library to our code with help from selenium import webdriver statement to launch the Firefox browser.

    Then we have to create a driver instance. It shall contain the webdriver.Firefox () where we have to specify the location of the geckodriver.exe file. This is done by setting up the executable_path property to the Firefox class constructor.

    Code Implementation to launch the Firefox browser.

    For running tests in the Internet Explorer browser, we need to download the IEDriverServer.exe file from https://www.selenium.dev/ and save it on a location.  In Python, we have to import the WebDriver library to our code with help from selenium import webdriver statement to launch the Internet Explorer browser.

    Then we have to create a driver instance. It shall contain the webdriver.Ie() where we have to specify the location of the IEDriverServer.exe file. This is done by setting up the executable_path property to the Ie class constructor

    Code Implementation to launch the Internet Explorer browser.

    Basic WebDriver commands in Selenium Python

    Let us discuss some of the common web driver commands used in Selenium Python.

    get() – This command is used for launching an application. This command will execute until the page load is complete. Then the program flow moves to the next step of test execution.

    current_url() – This command is used to fetch the URL of the application which is currently opened in the browser.

    title () – This command is used to fetch the title of the application which is currently opened in the browser.

    back() – This method is used to navigate back to the previously visited page and works only if we moved from one page to another page.

    forward () – This method is used to navigate forward from a previously visited page and works only if back() is used prior to its used.

    refresh () – This method is used to reload the existing page and refreshes it.

    maximize_window () – This method is used to maximize the window of an existing page. Some applications open in a maximized window by default, applying maximize_window () method on them shall not have any impact on them

    minimize_window () – This method is used to minimize the window of the existing page. Some applications open in minimized windows by default, applying minimize_window () method on them shall not have any impact on them.

    close () – This method is used to close the window in focus. Suppose there are two open windows, the second window is active currently, close () method if applied shall close only the second window where Selenium has the control.

    quit () – This method is used to close all the windows opened. Suppose there are two opened windows, the second window is active currently, quit () method if applied shall close all the driver sessions.

    Advanced Selenium WebDriver Python Tutorial

    We have also covered advanced topics of Selenium with Python. We will update the following topics along with advanced topics in the coming days. Bookmark this post to learn more.

    You can also check the official selenium python documentation here.

    Related Posts: 

    Selenium Python Tutorial

    Get our latest blog posts delivered to your inbox

    Subscribe and get popular blog posts about software testing industry.

    Rajkumar

    Leave a Comment

    Share via
    Copy link
    Powered by Social Snap