We are living in a digital world where almost every company is trying to provide their services to customers online either through websites, mobile applications, software packages, and so on.
So as the days keep increasing many companies are trying to shift the services online.so if any customer or client has to consume the service, the User Interface of that
Website or Application has to be attractive, otherwise, customers will never turn up for the service. And also it’s important to make sure that all the services provided should
behave as expected. There shouldn’t be any fault with the services. To ensure this we have to test it before the end product is visible to the customer. so testing it manually might not be efficiently possible, so the best approach is to go with Automation Testing Tools like Selenium WebDriver.
Selenium is not a single tool, rather it is a suite of tools.
Selenium is a collection (or) suite of 4 different tools.
Selenium IDE(Integrated Development Environment)
It is a tool that doesn’t require knowledge of any programming languages.
It is a beginner-friendly tool.
It is a Record and Playback tool.
It records the script and plays back that script.
Selenium Grid is basically a proxy server that basically supports cross-browser testing. It means you can run selenium scripts on multiple browsers.
Selenium Grid normally makes use of 2 components.
Hub is basically accepts the requests from the WebDriver client, and then it routes the JSON test commands to the remote drives on nodes.
It takes instructions from the client and run it across multiple machines simultaneously.
Node is a remote device that consists of a native operating system and a remote WebDriver. It receives requests from the hub in the form of JSON test commands and executes them using WebDriver
The commonly used tool or framework is Selenium WebDriver.
Windows, Apple OS X, Linux.
Why Selenium WebDriver?
1)Selenium WebDriver is one of the most popular tool in the market when it comes to automating Web Applications like Amazon, Facebook, etc.
2)It is open-source.
Python is one of the trending programming language around the world. Syntactically simple, yet powerful because of its libraries.
So, stepping in learning python is never a bad choice.
Q)Why Python with Selenium?
A)As Python is popular in the current era, learning Selenium with python is a very good decision to start your career as an Automation Test Engineer. There is no wastage of time spent learning python.
What are Web Applications?
Applications that run on Browser are called Web applications.
Ex: Facebook, Amazon, Flipkart, Gmail, and many more
Now let’s see how to install Python!!!
Visit the website http://python.org/download/ and there you can select the appropriate Operating System for which Python Software has to get downloaded.
Now let’s see how to install Selenium:
Selenium can be installed by using PIP Installer Tool. What exactly is this PIP?
PIP is a package installer tool used to install the packages to work with python.
We can Just Selenium through the terminal by using the command
pip install selenium
This command will install the Selenium WebDriver successfully on your system so you’ll be in a position to start writing the scripts.
In case is the Selenium is already installed, it can be updated to the latest version
By using the following command.
pip install -U selenium
-U tells that you are trying to update the selenium package.
from selenium import webdriver
You will import the webdriver from the selenium module first.
Now let’s see some of the frequently used methods in our Selenium Scripts:
Creating an object for the Chrome class will launch the Chrome Browser from your system.
Ex: driver = web driver.Chrome()
get() = This method is used to navigate to any website
quit() = This method is used to quit the Browser
Ex: driver. quit
close() = This method is used to close the current tab on your browser.
current_url = This method is used to get the URL associated with that particular webpage.
title = This method is used to get the Title associated with that webpage.
Ex: driver. title
send_keys = This method is used to enter the data into an input box.
click() = This method is used to click on a particular button available on the webpage.
clear() = This method is used to clear the data available in the input box.
Now let’s understand what role locators play in selenium!
If Selenium wants to perform an action on any of the elements like Entering the text in an input box, clicking on a button, getting the relevant data, selecting the drop-down, click on refresh options, and many more, first selenium has to identify that element, once the element is identified then the action can be performed on that element. So, to identify that particular element
We use the concept of locators.
Various locators available in Selenium are:
We can identify the elements available on the webpage using:
Id: Which uses find_element_by_id method.
Name: which used find_element_by_name method.
className: which uses find_element_by_class_name method.
Tag Name: which used find_element_by_tag_name method.
Link text: which uses find_element_by_link_text method.
Partial link text: which uses find_element_by_partial_link_text method.
Xpath: which uses find_element_by_xpath method.
CSS Selector: which uses find_element_by_css_selector method.
NOTE: All the above locators are used to identify only the first matching element at a time.
If we want to identify multiple elements, instead of using find_element we have to use find_elements, and the rest of everything will be the same.
Kiran , uday
Call the Trainer and Book your free demo Class for JAVA now!!!
© Copyright 2021 | Sevenmentor Pvt Ltd.