Since the advent of selenium there have been many plugin to test xPath / css selectors but you don’t need any of them if you have chrome browser. Using Chrome console you can test both xPath and css selectors. Launch website to be tested in chrome browser and hit F-12 and you would see chrome console opened in lower pane of application -
Hit escape key and console would open another pane to write element locators -
And now you can start writing xPath or css selectors in chrome console and test them -
The syntax for writing css id - $$(“
And hit the enter key. If your expression is right then html snippet of the application element corresponding to the css selector would be displayed -
If you mouse over the html snippet in chrome console then it would highlight the corresponding element in application -
If you want to clean console of previously written element selectors then just hit ctrl+L keys and chrome console would be empty again.
Process of testing xPath selector is same as css selector except that syntax to test xPath is -
So no more using any plugin to test element locators :-)
Is there any other innovative way you use to test your element locator?