filmov
tv
Different Locators available in Selenium WebDriver | Element Selection Strategies |

Показать описание
In this video, I have explained about Different Locators available in Selenium WebDriver.
Selenium WebDriver is an open-source tool for automated testing of web apps across many browsers.
One of the most fundamental techniques to learn when using WebDriver is how to find elements on the page. WebDriver offers a number of built-in selector types(locators) to achieve the same.
⭐ Element Selection Strategies or Locators ⭐
There are eight different built-in element location strategies or locators available in WebDriver:
id -- Locates elements whose ID attribute matches the search value
name -- Locates elements whose NAME attribute matches the search value
class name -- Locates elements whose class name contains the search value
tag name -- Locates elements whose tag name matches the search value
CSS selector -- Locates elements matching a CSS selector
XPath -- Locates elements matching an XPath expression
link text -- Locates anchor elements whose visible text matches the search value
partial link text -- Locates anchor elements whose visible text contains the search value. If multiple elements are matching, only the first one will be selected.
In general, if HTML IDs are available, unique, and consistently predictable, they are the preferred method for locating an element on a page. They tend to work very quickly and forego much processing that comes with complicated DOM traversals.
If unique IDs are unavailable, a well-written CSS selector is a preferred method of locating an element. XPath works as well as CSS selectors, but the syntax is complicated and frequently difficult to debug. Though XPath selectors are very flexible, they are typically not performance tested by browser vendors and tend to be quite slow.
Selection strategies based on linkText and partialLinkText have drawbacks in that they only work on link elements. Additionally, they call down to XPath selectors internally in WebDriver.
Tag name can be a dangerous way to locate elements. There are frequently multiple elements of the same tag present on the page. This is mostly useful when calling the findElements(By) method which returns a collection of elements.
The recommendation is to keep your locators as compact and readable as possible. Asking WebDriver to traverse the DOM structure is an expensive operation and the more you can narrow the scope of your search, the better.
-- Example: --
As seen in the example, locating elements in WebDriver is done on the WebDriver instance object. The findElement(By) method returns another fundamental object type, the WebElement.
WebDriver -- represents the browser
WebElement -- represents a particular DOM node (a control, e.g. a link or input field, etc.)
==============================================
************** Checkout my other playlists **************
==============================================
Java Programming videos playlist:👇
Selenium WebDriver with Java videos playlist:👇
Selenium interview questions videos playlist:👇
Windows automation with FlaUI videos playlist:👇
CSS Selectors videos playlist:👇
XPath videos playlist:👇
Javascript Executor videos playlist:👇
Apache POI videos playlist:👇
Maven videos playlist:👇
How to fix Eclipse errors:👇
==============================================
==============================================
Connect us @
==============================================
==============================================
🙏 Please Subscribe🔔 to start learning for FREE now, Also help your friends in learning the best by suggesting this channel.
#selenium #locators #selectorTypes #hyrtutorials #webAutomation
hyr tutorials,h y r tutorials,hyr,selenium webdriver tutorial,selenium tutorial,selenium tutorial for beginners,selenium training,selenium testing tutorial,automation testing tutorial for beginners,automation testing tools,selenium testing tool,selenium webdriver training,locators,selector types,css selector,linktext,partial linktext,locating element,locators in selenium webdriver,selenium locators best practices,xpath in selenium,locators in selenium
Selenium WebDriver is an open-source tool for automated testing of web apps across many browsers.
One of the most fundamental techniques to learn when using WebDriver is how to find elements on the page. WebDriver offers a number of built-in selector types(locators) to achieve the same.
⭐ Element Selection Strategies or Locators ⭐
There are eight different built-in element location strategies or locators available in WebDriver:
id -- Locates elements whose ID attribute matches the search value
name -- Locates elements whose NAME attribute matches the search value
class name -- Locates elements whose class name contains the search value
tag name -- Locates elements whose tag name matches the search value
CSS selector -- Locates elements matching a CSS selector
XPath -- Locates elements matching an XPath expression
link text -- Locates anchor elements whose visible text matches the search value
partial link text -- Locates anchor elements whose visible text contains the search value. If multiple elements are matching, only the first one will be selected.
In general, if HTML IDs are available, unique, and consistently predictable, they are the preferred method for locating an element on a page. They tend to work very quickly and forego much processing that comes with complicated DOM traversals.
If unique IDs are unavailable, a well-written CSS selector is a preferred method of locating an element. XPath works as well as CSS selectors, but the syntax is complicated and frequently difficult to debug. Though XPath selectors are very flexible, they are typically not performance tested by browser vendors and tend to be quite slow.
Selection strategies based on linkText and partialLinkText have drawbacks in that they only work on link elements. Additionally, they call down to XPath selectors internally in WebDriver.
Tag name can be a dangerous way to locate elements. There are frequently multiple elements of the same tag present on the page. This is mostly useful when calling the findElements(By) method which returns a collection of elements.
The recommendation is to keep your locators as compact and readable as possible. Asking WebDriver to traverse the DOM structure is an expensive operation and the more you can narrow the scope of your search, the better.
-- Example: --
As seen in the example, locating elements in WebDriver is done on the WebDriver instance object. The findElement(By) method returns another fundamental object type, the WebElement.
WebDriver -- represents the browser
WebElement -- represents a particular DOM node (a control, e.g. a link or input field, etc.)
==============================================
************** Checkout my other playlists **************
==============================================
Java Programming videos playlist:👇
Selenium WebDriver with Java videos playlist:👇
Selenium interview questions videos playlist:👇
Windows automation with FlaUI videos playlist:👇
CSS Selectors videos playlist:👇
XPath videos playlist:👇
Javascript Executor videos playlist:👇
Apache POI videos playlist:👇
Maven videos playlist:👇
How to fix Eclipse errors:👇
==============================================
==============================================
Connect us @
==============================================
==============================================
🙏 Please Subscribe🔔 to start learning for FREE now, Also help your friends in learning the best by suggesting this channel.
#selenium #locators #selectorTypes #hyrtutorials #webAutomation
hyr tutorials,h y r tutorials,hyr,selenium webdriver tutorial,selenium tutorial,selenium tutorial for beginners,selenium training,selenium testing tutorial,automation testing tutorial for beginners,automation testing tools,selenium testing tool,selenium webdriver training,locators,selector types,css selector,linktext,partial linktext,locating element,locators in selenium webdriver,selenium locators best practices,xpath in selenium,locators in selenium
Комментарии