Step by step selenium – step 3, what is findelement method

Selenium Basic


So far, we have learned how to launch a web browser, entering values in a text box and clicking button.
In this post, we will learn about findelement method.

Test automation is all about get and set, which means get from web and set into web.

Talking more specifically-

What I meant from get is, reading a webobject property e.g. Reading a label value of web, which is using findelement.

What I meant by set is, setting values in web for e.g. Inserting values in a text box, clicking a button, selecting a radio button, again using findelement method.

So findelement is a method which helps in interaction with a web page.

How it’s represented and does it work-

It’s written as –

Driver. Findelement(By. Id("")). Click().

WebDriver object allows access to findelement and with help of web object property is finds the designated object and perform operation.

There is another method which is known as findelements.

What is findelements()?

If a web object returns multiple values then findelements are used.

There should be some list, set or array variable be mentioned on the left side which can contain/store returned values-

It’s represented as-

List <WebElement> list= driver. Findelements(By. Id() ) ;

If you can compare with findelement method there is no click or get text method called. Same is done while in list object by iterating it Inside a loop.



el. Gettext() ;


Common Questions-

1- What is the difference bewteen findelement and findelements

Answer- Findelement return single element where as findelements return multiple elements

2- What is the data type which find element or findelements return.

Answer- String

3- What are possible cases when findelement return nothing or null or exception

Answer- Case 1- When page is not loaded when findelement is being called
Case 2- When element property is changed
Case 3- When there is a frame is introduced


Findelement, findelements method is accessed uding webdriver object whic is an interface. They helps in locating a web element or group of elements which have same properties.

It also helps in interaction which ultimately create a bridge between web page and you test/test data and execute test automation script.

Stay connected, In our next post we will learn how to find Xpath and CssSelector

String chromepath;
WebDriver driver;
chromepath = “./Resources/chromedriver”;
System.setProperty(“”, chromepath+”.exe” );
driver = new ChromeDriver();


driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);



WebDriverWait wait new WebDriverWait(driver, 45);

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Triggering SoapUI from selenium

The software industry has adopted Service Oriented Architecture-SOA, which consist of Microservices consist of SOAP and REST. Selenium is an API which helps in Web automation, Selenium does not help in API testing although SoapUI scripts can be invoked from selenium/Java classes. Using below 3 steps SOAPUI project can be …

Selenium Basic
Step by step selenium – step 4, Finding X-path…1/2

In Selenium test automation, if webobject properties does not have id, name, class then we left with 2 options- Option 1 calculate xpath Option 2 Calculate XssSelector In this post, we will calculate about the xpath and various XPath expression for webobjects whose attributed are changing dynamically. There are 2 …

Selenium Basic
Step by step selenium – step 2 -How to enter value in text box and how to click a button.

Abstract- In Previous post, we have learnt how to launch a web-browser in selenium. In this post we will learn how to enter values in a text box and how to click a button. We will be using chrome browser for this posts well. package TestNG_Classes; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; …