How can I get this element's text:
<span jsan="7.widget-pane-link,0.role" style="">Hi</span>
In other words, how can I get the text Hi
by Using attribute GetAttribute("jsan")
?
How can I get this element's text:
<span jsan="7.widget-pane-link,0.role" style="">Hi</span>
In other words, how can I get the text Hi
by Using attribute GetAttribute("jsan")
?
To retrieve the text Hi from the element you have to induce WebDriverWait for ElementIsVisible()
and you can use either of the following Locator Strategies as solutions:
Using CssSelector and Text property:
Console.WriteLine(new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementIsVisible(By.CssSelector("span[jsan*='widget-pane-link'][jsan$='role']"))).Text);
Using XPath and GetAttribute() method:
Console.WriteLine(new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementIsVisible(By.XPath("//span[contains(@jsan, 'widget-pane-link') and contains(@jsan, 'role')]"))).GetAttribute("innerHTML"));