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.

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.

  • Thanks. A quick ctrl F in the Dev tools brought up the all important field to let me check by locator. – Matt Feb 1 '18 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.

  • Great idea. I think ill do this. Cheers – Matt Feb 2 '18 at 2:57
  • Yes, it helps.Please try it and let us all know. – Vishal Aggarwal Feb 2 '18 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. – João Farias Feb 2 '18 at 17:23
  • No, I am not assuming that, all I am saying it instead of doing it manually , use automation. – Vishal Aggarwal Feb 3 '18 at 23:10
  • Each page will be different so will be it's locators and definition of 'verifyLocators' methods. – Vishal Aggarwal Feb 3 '18 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, privacy policy and cookie policy

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