Different Locators available in Selenium WebDriver | Element Selection Strategies |

  Рет қаралды 18,891

H Y R Tutorials

H Y R Tutorials

4 жыл бұрын

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: --
WebElement cheese = driver.findElement(By.id("cheese"));
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:👇
🔗 bit.ly/3keRJGa
Selenium WebDriver with Java videos playlist:👇
🔗 bit.ly/2FyKvxj
Selenium interview questions videos playlist:👇
🔗 bit.ly/3matUB3
Windows automation with FlaUI videos playlist:👇
🔗 bit.ly/33CG4dB
CSS Selectors videos playlist:👇
🔗 bit.ly/2Rn0IbD
XPath videos playlist:👇
🔗 bit.ly/2RlLdkw
Javascript Executor videos playlist:👇
🔗 bit.ly/2FhNXwS
Apache POI videos playlist:👇
🔗 bit.ly/2RrngrH
Maven videos playlist:👇
🔗 bit.ly/2DYfYZE
How to fix Eclipse errors:👇
🔗 bit.ly/3ipvNYf
==============================================
==============================================
Connect us @
🔗 Website - www.hyrtutorials.com
🔗 Facebook - HYRTutorials
🔗 LinkedIn - www.linkedin.com/company/hyrtutorials
🔗 Twitter - Hyrtutorials
==============================================
==============================================
🙏 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

Пікірлер: 36
@HYRTutorials
@HYRTutorials 4 жыл бұрын
Please use the below link for the selenium videos playlist: 🔗 bit.ly/2FyKvxj
@jean-paulboga8189
@jean-paulboga8189 6 ай бұрын
great course thanks sir
@MrSayandeep
@MrSayandeep 3 жыл бұрын
Lucid explanation. Please cover more on CSSelectors
@HYRTutorials
@HYRTutorials 3 жыл бұрын
Check out this playlist kzfaq.info/sun/PLacgMXFs7kl8E5xl-nu_7ZjHN0O4oiFcl
@sahithi_purushoth506
@sahithi_purushoth506 10 ай бұрын
Hello sir Your explanation is very easy to understand it's so useful thank you sir😊 Could you please explain to TOSCA too..
@durgaprasad-ng8ez
@durgaprasad-ng8ez 4 жыл бұрын
Good explination
@HYRTutorials
@HYRTutorials 3 жыл бұрын
Thankyou, Keep watching 😊
@chirrachandrashekhar5886
@chirrachandrashekhar5886 3 жыл бұрын
good explanation
@HYRTutorials
@HYRTutorials 3 жыл бұрын
Thankyou, Keep watching
@sridevilanka6940
@sridevilanka6940 4 жыл бұрын
Hi Yadagiri Reddy, can you please do a video on how to get cell value from a grid in wpf using FlaUI. Thank you,
@HYRTutorials
@HYRTutorials 4 жыл бұрын
Hi Sridevi, You can use patterns to achieve this. If it supports grid pattern u can use that. Soon will make a video on patterns.
@sridevilanka6940
@sridevilanka6940 4 жыл бұрын
Yes, it supports grid pattern but couldn't make it work. Very happy to hear that you are going to make a video on patterns. Thank you. I tried the below sample but couldn't make it work. Here is the link to it github.com/FlaUI/FlaUI/blob/master/src/FlaUI.Core.UITests/Patterns/GridPatternTests.cs
@bhavyaambati9433
@bhavyaambati9433 9 ай бұрын
can please make a video on intelliJ for Automation Testing
@hiteshshah5058
@hiteshshah5058 4 жыл бұрын
We can also automate salesforce application by using selenium, do you have any series/link/experience regarding, apart from web application. I am working as Salesforce QA and want to automate now. Thanks in advance
@HYRTutorials
@HYRTutorials 4 жыл бұрын
No Hitesh, as of now I don't have any series on that.
@balakrishna5786
@balakrishna5786 2 жыл бұрын
nice explanation
@HYRTutorials
@HYRTutorials 2 жыл бұрын
Thanks buddy 😊
@durgaprasad-ng8ez
@durgaprasad-ng8ez 4 жыл бұрын
Please do videos on Maven and Gradle also
@HYRTutorials
@HYRTutorials 4 жыл бұрын
Yeah sure will make them
@VijayKumar-hm5jt
@VijayKumar-hm5jt 2 жыл бұрын
SupeR siR
@HYRTutorials
@HYRTutorials 2 жыл бұрын
Thankyou buddy 😊
@prasadparadkar8750
@prasadparadkar8750 2 жыл бұрын
Hey can you help me with the problem I'm facing. By clicking F12 developer tools opens up and we inspect a certain element. But when i'm trying to right click in console to copy xpath the right click isn't working I mean the shortcut way. Can you suggest something.
@HYRTutorials
@HYRTutorials 2 жыл бұрын
Without shortcut,are you able to perform right click operation?
@prasadparadkar8750
@prasadparadkar8750 2 жыл бұрын
@@HYRTutorials I can right click on any website to inspect it but can’t right click in console to directly copy xpath or full xpath. I hope you’re getting it what i’m trying to say.
@prasadparadkar8750
@prasadparadkar8750 2 жыл бұрын
@@HYRTutorials Yes I can right click to inspect any website but in console I can’t right click to copy xpath or full xpath.
@HYRTutorials
@HYRTutorials 2 жыл бұрын
Thats strange. is this happening in your local system or office system?
@prasadparadkar8750
@prasadparadkar8750 2 жыл бұрын
@@HYRTutorials My local system. One more weird thing is I can right click in automated browser window console to copy xpath but not in normal broswer window.
@manimungara170
@manimungara170 Жыл бұрын
How to remove error in selenium program
@HYRTutorials
@HYRTutorials Жыл бұрын
It depends on error buddy. But for sure without resolving the error it will not go away
@yeliza2350
@yeliza2350 2 жыл бұрын
25 February.done
@HYRTutorials
@HYRTutorials 2 жыл бұрын
Thankyou 😊
@deepthichanda2840
@deepthichanda2840 2 жыл бұрын
Hi Hyr Tutorials, Greetings, I have no exposure to java started learning with your vedios. i have instlled eclipse as per your vedioguide. stuck up with this error can you plese help me understand. its throwing error WebDriverWait mywait = new WebDriverWait(driver,20); **The constructor WebDriverWait(WebDriver, int) is undefined** driver.findElement(By.tagName("input")).sendKeys("vedanshichanda969");
@HYRTutorials
@HYRTutorials 2 жыл бұрын
Instead of passing 20 directly, pass it like this Duration.ofseconds(20)
@deepthichanda2840
@deepthichanda2840 2 жыл бұрын
@@HYRTutorials thanks for the early reply andi corrected to it
Amazing weight loss transformation !! 😱😱
00:24
Tibo InShape
Рет қаралды 67 МЛН
Sigma girl and soap bubbles by Secret Vlog
00:37
Secret Vlog
Рет қаралды 15 МЛН
Son ❤️ #shorts by Leisi Show
00:41
Leisi Show
Рет қаралды 8 МЛН
CSS Combinator selectors | Selenium WebDriver | CSS Selectors |
11:48
H Y R Tutorials
Рет қаралды 7 М.
Locators In Selenium Webdriver- Which locator in Best for Automation?
28:08
Locators in Selenium WebDriver | Ultimate Guide for Beginners |  Day 10
18:13
The Testing Academy
Рет қаралды 10 М.
How to Handle Frames in Selenium WebDriver
21:20
H Y R Tutorials
Рет қаралды 57 М.
Enter Text into a Textbox using JavascriptExecutor in Selenium WebDriver
17:11
Amazing weight loss transformation !! 😱😱
00:24
Tibo InShape
Рет қаралды 67 МЛН