Using Firebug, inspect the Password text box in Facebook and notice that it has the same name as the Email or Phone text box. Sumasri is a Sr. If no element has a matching link text attribute, a NoSuchElementException will be raised. The DOM strategy works by locating elements that matches the javascript expression refering to an element in the DOM of the page. She writes here about Manual Testing and Automation Testing.

Uploader: Zull
Date Added: 3 September 2016
File Size: 47.80 Mb
Operating Systems: Windows NT/2000/XP/2003/2003/7/8/10 MacOS 10/X
Downloads: 90449
Price: Free* [*Free Regsitration Required]

Selenium uses what is flement locators to find and match the elements of your page that it needs to interact with. In certain Selenium Automation Tests, there is a need to control keyboard or Filters are additional attributes used to distinguish elements with the same name.

Types of Element Locators – Web Performance

Powered by Sphinx 1. It should take you to the Flight Finder page shown below. It is our efforts to share every bit we know about the Selenium so that you can use it successfully in your live projects.

We will access the ‘Email or Phone’ text box first. Selenium IDE should be able to highlight the orange box as shown below.

Types of Element Locators

Use this when you want to locate an element by CSS selector syntax. What criterias are relevant when choosing a locator strategy?


Selenium IDE should be able to access the Phone text box correctly. The CSS class locator uses a specific class attribute to get to the first element on a web page. Locating by DOM – dom: The form in that page has no name and ID attribute, so this will make a good example. First, make sure that you are logged off from Mercury Tours.

Selenium Tutorial: Locators

This strategy is intended to select links only and selects the anchor element containing the leement text: It is very helpful when we want to extract the content within a Tag. It should go through the login page Adds a suggestion that is rated as moderate and public Then it tests that your suggestion has been added and is present on the suggestions page Finally, it deletes the suggestion. In the above example, the input field could be easily located using either the id or the field name.

Refer to the image below. XPath allows you to navigate that structure. So, how do we access them?

Selenium provides the following methods to locate elements in a page:. We use above mentioned method to locate elements but the locator part will be replaced with the locator names.

There are also a couple of very useful Add-ons that can assist in discovering the XPath of an element:.


And, we end up working with wrong elements or unable to find them. Any element on the page can be located via one or webvriver XPaths and most other locators can be expressed as an XPath.

Element Locator – Chrome Web Store

Valid XPath locators can be:. XPath locators can also be used to specify elements via attributes other than id and name. A Scrollbar is a lets you move around screen in horizontal or vertical You can also specify a filter to refine your locator.

In this tutorial, we will toggle between Facebook, new tours. Alternatively, you can use the element’s name instead of its index and obtain the same result. With this strategy, the first element with the given tag name will be returned.

In the following example, we will access an image that cannot possibly be accessed through the methods we discussed earlier.