2

I'm wondering what people use as a quick check to verify their locators are correct?

I'm currently putting in my locators and running a test which then tells me if the locator is correct. This can take a while as some scenarios take a bit of time to reach the step where my new locator is.

Is there a quick way of verifying a locator in isolation without having to run the entire test? I saw Firefinder used to do this but that plugin seems to be no more.

0

3 Answers 3

4

On Chrome, using the "Developer" tool, in the "Elements" tab, you can search for elements using selectors and XPaths. So no plugin is required. It is also returning the number of elements targeted with that selector.

1
  • Thanks. A quick ctrl F in the Dev tools brought up the all important field to let me check by locator.
    – Matt
    Feb 1, 2018 at 8:38
1

How about having an general method called 'verifyLocators' under every page object and then writing an simple test to navigate each page in the application and call these respective page methods.

This is much faster as it is automated compared to manually typing and verifiying each locator under Dev tools .Try it.

Although one caveat , it will not cover all the locators but most of them which are available on page load.

5
  • Great idea. I think ill do this. Cheers
    – Matt
    Feb 2, 2018 at 2:57
  • Yes, it helps.Please try it and let us all know. Feb 2, 2018 at 9:56
  • 1
    The problem with this is that you are assuming each page, for each test, has the same structure - regardless of the setup data of the tests. Feb 2, 2018 at 17:23
  • No, I am not assuming that, all I am saying it instead of doing it manually , use automation. Feb 3, 2018 at 23:10
  • Each page will be different so will be it's locators and definition of 'verifyLocators' methods. Feb 3, 2018 at 23:12
0

In case of CSS Selectors and Xpaths, many times we have to construct our own locators. In order to verify these selectors, you can go to Console in the Chrome developer tools and use $$yourcss_selector or $xyourxpath_selectorto verify if the selector is correct.

A very detailed explanation is here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.