I am trying to select this element using chromedriver selenium:
<span title="1968milziewa@ama-coupons.com" class="rcmContactAddress">1968milziewa@ama-coupons.com</span>
where the email address is a variable.
Tried this, but doesn't work:
driver.FindElement(By.XPath("//span[text()='" + username + "@ama-coupons.com']")).Click();
also tried this:
driver.FindElement(By.XPath("//span[contains(@title, '"+username+"@ama-coupons.com']")).Click();
but it doesn't work either. #1 gives element not found #2 gives not a valid xpath selector.
UPDATE:
I had it work with a hard-coded email address, however, as soon as I replace that email address with a variable, it doesn't work anymore.
HTML Element:
<span title="1959jessamin@ama-coupons.com" class="rcmContactAddress">1959jessamin@ama-coupons.com</span>
code:
new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.CssSelector("span[title='"+email+"']"))).Click(); Thread.Sleep(1000);
Error: (which also shows the value of email:)
Inner Exception 1:
NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"span[title='1959Jessamin@ama-coupons.com']"}
(Session info: chrome=68.0.3440.106)
(Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 10.0.17134 x86_64)