Xpath to CSS //span[text()='Login'] to CSS ...?

I usually use xpath locators in my tests and slowly I am converting them to CSS.

I haven’t found a way to change this xapth //span[text()=‘Login’] to css

Can some one help.

span:contains(‘Login’) // doesn’t work


try this, but i am not sure is this secure


Thanks … I have tried cssify already … but doesn’t work.

is there any browser add on for ff or chrome, e.g this add on

CSS can’t select elements by containing text.

You could try using jQuery, if xpath is not working for you.

Hi @Mate_Mrse,

Does CSS support exact text?

Regarding jQuery … Can you please tell how ?

CSS doesn’t support exact text.

You could use


inside of a javascript executor:

WebUI.executeJavaScript('return $("span:contains(‘Login’)") ', [])

You will probably need to escape some characters there :smiley: . Sorry, don’t have time to check.

1 Like