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, 2019 in Selenium by Kapil
60 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, 2019 by Kabir

Related Questions In Selenium

0 votes
2 answers
0 votes
1 answer

Which click command can be used to click on a specific part of webpage in Selenium?

Hi Apeksha, in Selenium IDE to click on ...READ MORE

answered Oct 17, 2019 in Selenium by Devesh
291 views
0 votes
2 answers

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,520 points
3,781 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,762 views
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,890 points
2,740 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
3,108 views
+2 votes
3 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
• 57,700 points
166 views
0 votes
2 answers