Hope you\'re all well. I\'m quite new to selenium and a complete newbie to stack overflowso i hope i\'m not disobeying any rules here.
I am trying to create a test f
IWebElement element = driver.FindElement(By.XPath("//span[contains(@class'com') and normalize-space(translate(., '\u00A0', ' '))='Alumina MB China metallurgical grade delivered']"));
Explanation:
Use xpath to find a span
element with class containing the string com
, get the text from that (.
) replace all of the  
characters (i.e. unicode \u00A0
) with a regular space
character, and strip leading and trailing whitespace (this last part may not be needed in your situation).
Note: the string that should go in the single quotes after the =
should only contain regular spaces.
Try to escape html characters by using System.Web.HttpUtility.HtmlDecode
it works for me:
var escaped = System.Web.HttpUtility.HtmlDecode(".//span[text()='Alumina MB China metallurgical grade delivered duty paid RBM/tonne']");
IWebElement element = driver.FindElement(By.XPath(escaped));
you should first replace all instances of $nbsp;
in your xpath string to and then search for that