c# - How to use Selenium to grab nested LinkText? -
i'm using selenium in c# click on link called 'store locator'. current code follows not click on link:
iwebelement storelink = driver.findelement(by.linktext("store locator"));
here original html, notice there span element nested in tag, not sure if makes difference.
<a href="/site/olspage.jsp?id=cat12090&type=page&rdct=n" data-lid="hdr_stl"><span class="header-icon-storefinder" aria-hidden="true"></span>store locator</a>
seems link hidden. if selenium
finds link not able interact directly. in case javascript option
by xpath = by.xpath("//span[contains(text(),'store locator')]"); iwebelement element = driver.findelement(xpath); ((ijavascriptexecutor)driver).executescript(@"arguments[0].click();",element);
Comments
Post a Comment