Which is the best way to locate an element?

Which is the best way to locate an element?

The most preferred, the easiest and efficient way to locate an element on a web page is By ID. Id will the attribute on the page which will be unique like you bank account number or employee id. Ids are the safest and fastest locator option and should always be the first choice even when there are multiple choices.

What are the elements of a web page?

Some of the most common web page elements you will encounter include:

  • Links.
  • Paragraphs.
  • Headings.
  • Numbered and bulleted lists.
  • Tables.
  • Regions.
  • Images.
  • Form controls including radio buttons, edit fields, check boxes, combo boxes, list boxes, and buttons.

What are the locators to find web elements?

There are different types of web element locators and it is up to you to decide which one to take in use. If one locator works for you then that may not work for others. Nevertheless, the work performed by different locators is same.

How to locate web elements in Google Chrome?

Like Firebug in Firefox, Google Chrome has its own developer tool that can be used to identify and locate web elements on the web page. Unlike firebug, a user is not required to download or install any separate plugin; the developer tool comes readily bundled with Google Chrome.

How to find web elements by same ID?

Without thinking much, copy the value of ID attribute of text box and click on console. Now type as shown below and press enter: Expend the result. You will see one field named “length” which says how many web elements have same id in web page or how many elements are located by same id.

How to locate web elements in selenium Part 1?

Before we learn about how to locate web elements, let’s start with basics of HTML. HTML stands for Hyper Text Markup Language which describes structure of a web page. Every web page will have text box, buttons, drop down, lists etc. These are called html elements or web elements.