About - Selenium

Definition

Development and Versions

Pre-requisites

Languages supported

Manual vs Automation

Choosing Selenium

Selenium - Components

Selenium IDE

Selenium RC

Selenium WebDriver

Selenium Grid

QTP

Selenium vs QTP

Selenium - IDE

Features

Install and configure

Selenium - Webdriver

About WebDriver

install and configure

First test case

Web element

Element Locators

Example of locators

Chropath

Web driver commands

Eclipse and TestNG

About Eclipse

Choose and download

About TestNG

Testng installation on eclipse

Testng Annotations

Pass Fail and Skip test cases

Run test cases in batch

testng.xml - Explanation

testng grouping

Running tests parallely

dependsOnMethods

dependsOnGroups

Prioritization

Passing parameters

Data providers

Read data from excel

Ant - XSLT reports

Testng listeners

Cross browser testing

Page Object Model



About Selenium - Definition
 
WebElement is any element/part in the page of a browser which holds some functionality to be performed on the element itself by users of the website

Now we will see the operations that we can do on different Elements on web page.

Before doing so, first we need to identify what are the different types of elements:

They are as follows:

1) EditBox/TextBox

2) Button

3) DropDown

4) TextArea

5) Link

6) Radio button

7) CheckBox

8) Image,Image link and Image button

Example:

Let us see the code to identify element in the browser:

After creating driver object, the following code is used identify the TextBox/EditBox element.

driver.findElement(By.id("username")).sendKeys("Ananda");

There are two methods to identify web elements. Those are findElement(); and findElements();

By defines by which identifier/locator here it is "id"

username is the identfier/locator of the Editbox with code in html as follows:

"input type="text" name="username" id="username"




1) EditBox/TextBox: The operations that we can perform on Edit Box is writing text inside the box and deleting the text from the box. For writing the keys we use sendKeys("text") method

Eg: driver.findElement(By.name("username")).sendKeys("Ananda");

If you want to delete the text, you can use clear() method
Eg: driver.findElement(By.name("username")).clear();

If you want to first send the text, the field should be enabled first, for checking that you can use isEnabled () method which returns Boolean.
Eg: driver.findElement(By.name("username")). isEnabled ();

2) Button: The operations that we can perform on Submit button is clicking on the button. For that use click() or submit() method;
Eg: driver.findElement(By.name("Submit")).click(); Eg: driver.findElement(By.name("Submit")).submit();

If you want to first click on the button, the button should be enabled first, for checking that you can use isEnabled () method which returns Boolean.
Eg: driver.findElement(By.name("Submit")). isEnabled ();

3) DropDown: The following operations can be performed on DropDown box.

a) If you want to first select the value in dropdown, the box should be enabled first, for checking that you can use isEnabled () method which returns Boolean
Eg: driver.findElement(By.name("dropdown")). isEnabled ();

b) If you want to select any value in the dropdown you need to follow the below steps:
Select seleDropDown=new Select (driver.findElement(By.name("dropDown"))); seleDropDown.selectByIndex(0); seleDropDown.selectByValue("country1"); seleDropDown.selectByVisibleText("India");

if you want to deselect, the following code applies.
seleDropDown.deSelectByIndex(0); seleDropDown.deSelectByValue("country1"); seleDropDown.deSelectByVisibleText("India");

The actual dropdown in html is like this: Here starting index is 0 which corresponds to India

c) If you want to know the item count ,you need to do the following steps
System.out.println("Size: "+seleDropDown.getOptions().size());

d) isMultiple() to check if multiple options can be selected. e) deSelectall(),selectAll(),getAllSelected() etc.. and other important operations.

4) TextArea: The following operations can be performed on TextArea. Get the text in that text area locator.
Eg: driver.findElement(By.name("textArea")). getText ();

5) Link: The following operations can be performed on Link Element: a) Click on the link.
Eg: driver.findElement(By.name("link")). Click();

6)Radio The following operations can be performed on Radio button Element: b) Click and is selected
Eg: driver.findElement(By.name("radio")).isSelected(); driver.findElement(By.name("radio")).click();

7) CheckBox:The following operations can be performed on CheckBox Element: c) isEnabled, isSelected and Click.
Eg: driver.findElement(By.name("checkBox")).isSelected();
driver.findElement(By.name("checkBox")).click();
driver.findElement(By.name("checkBox")).isEnabled();

8) Image/Image Link/Image button
a) Image: There are no operations that can be performed on normal Image
b) Image Link: Click() operation can be performed
c) Image button: isEnabled(), Click() and Submit() operations can be performed
Eg: driver.findElement(By.name("image")).Submit();
driver.findElement(By.name("image")).click();
driver.findElement(By.name("image")).isEnabled();

I conduct online tutions on Manual Testing, Selenium and the following. For more details contact anandaibmindia@gmail.com
Manual Testing - 1600/-           Selenium - 1600/-
           Jsp and Servlet -2000/-           Java training - 2000/-