Showing posts with label selenium introduction. Show all posts
Showing posts with label selenium introduction. Show all posts

Friday, 30 June 2017

Selenium WebDriver : Working with Drop-down Options

So, by now you must have learnt about how to open a Web Page, Navigate to another page by clicking on a link, click a button or verify text present on the Web Page. If not, you need to practice these basic User Actions that can be performed through Automation. You can also check the videos which explains about the different things that we have already discussed and will be discussing in the upcoming posts, related to Test Automation using Selenium WebDriver.

 YouTube Channel : Click Here

In this post we are going to learn yet another important feature of Selenium WebDriver, that is Selecting one of the Drop-down Options.

Before we see how to use the methods provided by Selenium WebDriver to select Drop-down Options, we need to initialize the Object which we will be using to Select options. Following line of code will find the <select> tag in HTML source code, and assign it to an object which we can use to call different methods :



Select option = new Select(driver.findElement("<select> tag locator"));

Once we have initialized the Object, we are ready to use the Object to call different methods.


There are different ways of selecting Drop-down option, let's see them one by one :


1 - Select By Visible Text :

You can select options based on the values displayed in the drop-down list.


option.selectByVisibleText("Option text String");

This will select the option based on the String passed as parameter to above mentioned method.


2 - Select by Value :


option.selectByValue("Option value attribute");

You can find the value attribute of the <option> tag in the HTML source code.

  

3 - Select by Index :


option.selectByIndex(index);

index is 0-based (starts from zero), to be incremented by one for next option.



In this way we can Select any of the Drop-down options using any of the methods provided by Selenium WebDriver.

Feel free to comment in the comments section in case you have any queries.
Happy Learning.

Don't forget to Subscribe :
YouTube Channel : Click Here

Thursday, 21 May 2015

Selenium - Test Automation Tool Introduction

Selenium is a Software Test Automation Framework used to automate Web-based Applications. It is a collection of tools which can be used to perform various tasks.

Selenium is used to automate test cases related to Web Pages that are frozen and will not change in the near future. We can say that "Manual Testing" can be partially replaced by "Selenium (Automation)" to test most of the features on Web Pages.


Why To Automate ?


The first question that comes in our mind is: Why there is a need to automate Web-based Applications? There are lots of things on a web page which requires our attention as far as testing is concerned, in order to deliver a perfect error-free optimized product. In such cases, it is difficult to track each and everything on a Website (presence of text boxes, functionality of buttons, etc).
For such reasons, Selenium was developed so that anyone with/without programming background can test basic functionalities/UI (User Interface) elements and include such automated test cases in Sanity/Regression suites!! Even if you are not familiar with programming, don't worry, Selenium provides its hassle free "Record And Playback" feature via Selenium-IDE.
Another reason is, Automation Scripts are not error prone when required to be executed multiple times, which allows us to use one of the Test Automation tool.



What To Automate ?

  • Functionalities that are not going to change in the near future.
  • Regression Testing.
  • Test Cases that takes more time to execute.
  • Test Cases that are error-prone and are very important.
  • Test Cases that require huge amount of input data.
  • Test Cases that includes Repeated Tasks.


What NOT To Automate ?

  • Functionalities that change frequently.
  • When a quick manual testing will do the job instead of Automation Script.
  • Testing the functionality for the first time.


Selenium Testing Framework Tools

Selenium IDE :

  • Very important tool for those who are not familiar with Programming.
  • Provides "Record and Playback" feature.
  • Contains various other features such as running a single/multiple test cases, test suites, controlling speed of execution, finding and highlighting UI elements and many more.
  • Its a Firefox Add-On.

Selenium RC :

  • It requires a standalone server for its execution
  • Needs a programming background.
Officially it has been deprecated so we will not go in detail.

Selenium WebDriver :

  • One of the most popular tool for Test Automation.
  • Programming background is needed.
  • Supports programming languages such as Java, Python, C#, etc.
  • Can automate almost any task on any Web Application.
  • Unlike Selenium RC, it doesn't require standalone server for its execution.

Selenium Grid :

  • Used to perform automation on remote machines.
  • Consist of one Hub and multiple Nodes.
  • Hub controls the execution of code on various Nodes.
  • This helps in parallel automation on different browsers and machines.


Will discuss these in upcoming posts.
Happy Learning.



YouTube Channel : Click Here