Which of the locators should be used when?

0 votes
Which of the id, name, XPath or CSS selector should be used in different scenerios?
Jun 21 in Selenium by Kapil
25 views

1 answer to this question.

0 votes

Hi @Kapil, you should use ID or Name as locators if the page has unique names or identifiers available. If they are not available, then you can go for a CSS selector as it is faster than the XPath. When none of the preferred locators is present, then you can try the XPath, as it helps you in identifying even the complex elements.

answered Jun 24 by Kabir

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer

How to handle a combobox which when clicked open in new window with list of items(to be clicked) in selenium java ?

@Pavithra, you can try using following commands ...READ MORE

answered Oct 29 in Selenium by Abha
• 27,180 points
151 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
943 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,121 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
859 views
+2 votes
2 answers

What are the different Locators that can be used to access Web Elements?

@Nitesh, I would like to tell you ...READ MORE

answered Dec 12, 2018 in Selenium by Priyaj
• 56,920 points
74 views
0 votes
1 answer