We are going to find an element on the page by using the findElementById() method that is on each of the Browser Driver classes. findElement calls will return a WebElement object that we can perform actions on.
Follow these steps to see how it works:
Open your Java IDE. Intellij or Eclipse are the most used.
We are going to use the command:WebElement element = ((FindsById)driver). findElementById("verifybutton");
Run the test from the IDE. It will look like the following screenshot:
What just happened?
We have just seen how we can find an element by using the findElementByld helper method. After running the test, we saw that it passed. This meant that it found the element. If an element is not found in Selenium, WebDriver will throw a NoSuchElementFoundException exception.
Finding elements on the page by their ID
In addition to findElementByld, there is findElementsBylD. This call has been added to the API so that there is symmetry in the API even though it is against the HTML spec to have more than one item in the DOM with an ID. We will now see how we can use it in action. The method's signature looks like:findElementsById(String using);
The using variable takes the ID of the element that you wish to look for. It will return a WebElement object that we can then work with.
Selenium Related Interview Questions
|SILK TEST Interview Questions||QTP Interview Questions|
|JMeter Interview Questions||Automation Testing Interview Questions|
|Software testing Interview Questions||JUnit Interview Questions|
|TestNG Interview Questions||SAP Testing Interview Questions|
|Selenium WebDriver Interview Questions||Selenium IDE Interview Questions|
|QUnit Testing Interview Questions||Performance Testing Interview Questions|
|Hadoop Testing Interview Questions|
Getting Started With Selenium Ide
Overview Of Selenium Webdriver
Working With Webdriver
Getting Started With Selenium Grid
Advanced User Interactions
Working With Html5
Migrating From Remote Control To Webdriver
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.