Locators can be classified into two categories: Locating elements using Name is same as locating elements using ID locator. Sometimes, you end up working with incorrect GUI elements or no elements at all! If no element has a matching name attribute, a NoSuchElementException will be raised. First, make sure that you are logged off from Mercury Tours.

Uploader: Daizil
Date Added: 13 November 2016
File Size: 30.87 Mb
Operating Systems: Windows NT/2000/XP/2003/2003/7/8/10 MacOS 10/X
Downloads: 74611
Price: Free* [*Free Regsitration Required]

If not, check out the link mentioned below:. Caution As a general rule, keep in mind that if a locator matches several elements, only the first one will be effectively used by Selenium. Fortunately, Firebug can automatically generate Wegdriver locators.

As a general rule, keep in mind that if a locator matches several elements, only the first one will be effectively used by Selenium. Every form has input fields with unique names. Locators in Selenium IDE: Any element on the page can be located via one or more XPaths and most other locators can be expressed as an XPath. This value should always be enclosed in a pair of parentheses “”.

8 Ways to Use Locators in Selenium Test Automation Projects

Notice that the form containing it has no ID and name attributes. Notice that it is contained in a form named “home.


The text locator looks for elements with that contain the supplied text. Identification of correct GUI elements is a prerequisite to creating an automation script.

Locators in Selenium WebDriver | Selenium Tutorial

You have to know the text epement the link before. Mentioned few examples below for reference. And you would be able to use locators in Selenium projects more efficiently than ever before.

Sign up to receive new product announcements Send. The choice of locator depends largely on your Application Under Test.

It starts from the root element within the web page or part of the page and goes to identify the target element. You can use the most appropriate one for your case. They can help you perform actions which are difficult to do with XPath. It is handy for finding links and buttons on the page that have visible text locatore not an image that contains the text.

A well-written XPath can be very robust, but a poor XPath can be fragile — meaning that it may break when the application changes. If it appears in a list or table, then there is a good chance that the IDs can change for future visits to the page and a more complex locator may be required. About The Author Harsh S.

Recent Drivers  DRIVER: GA-MA69GM-S2H

Use this demo page http: XPath is designed to allow the navigation of XML documents, with the purpose of selecting individual elements, attributes, or some other part of an XML document for specific processing. The Phone text box should still become highlighted. In general, field names are unique to the form, but not always. Easily matches several elements: What is a Scrollbar? This is useful for locating items that have a unique style on the page.

Click the Find button and notice that the “Email or Phone” text box becomes highlighted with yellow and bordered with green, meaning, Selenium IDE was able to locate that element correctly.

However, they can do some things easily that is somewhat hard to do with XPath. In Selenium IDE, type “document. Loxators Name locator is used to find the elements matching the specified Tag Name. Click on the Find button.