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
17 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

How do I set the zoom level of Internet Explorer to 100% when using python _winreg

My qustion is, by default for testing ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,050 points
668 views
0 votes
1 answer

what is the need of xpath when you have attributes like id ,class,name in selenium?

It is not necessary that every element ...READ MORE

answered Jun 1, 2018 in Selenium by Vinita
• 220 points
92 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,050 points
259 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
629 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
257 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,160 points
50 views
0 votes
1 answer