selenium-webdriversvgxpathwebdynpro

How to write xpath for an element containing '&nbsp' and svg tag in between?


I am trying to get the xpath of the highlighted element(span) in the below image.

I tried the below options and none of them are working:

 //span[contains(text(),'Database')]
 //span[ends-with(., 'Database')]
 //span[text()='\u00A0\u00A0Database']
 //span[contains(., '\u00A0\u00A0Database')]

Solution

  • Given the HTML:

    html

    The desired text &nbsp;Database is within the <span>.


    Solution

    To locate the element you can use either of the following locator strategies:


    References

    You can find a couple of relevant detailed discussion in: