I am trying to retrieve a hyperlink element in Selenium in which the link is actually executing javascript. I am unable to retrieve it despite trying several different methods.
< < NOTE: I am able to retrieve other controls - just struggling with this one > > The element looks like the following; trying to retrieve the test1_decode one:
<section id="specialsection" role="tabpanel" aria-hidden="true">
<ul class="col4">
<li class="header2"><a href="javascript:SetApplication('test1_decode');">Example Application</a></li>
<li class="header2"><a href="javascript:SetApplication('test2_decode');">Example Application POC</a></li>
</ul>
</section>
I've tried the following: FindElement using XPath contains link text, FindElement using Xpath contains text, FindElement by PartialLinkText, FindElement by LinkText - all fail.
I even tried getting all < a > in a list; I wonder if maybe it's because it has a 0 height?
//These are the different things I've tried:
IWebElement ExAppLogin = driver.FindElement(By.XPath("//a[contains(text(), 'Example Application')]"));
IWebElement ExAppLogin = driver.FindElement(By.XPath("//a[contains(@href, 'test1_decode')]"));
IWebElement ExAppLogin = driver.FindElement(By.PartialLinkText("test1_decode"));
IWebElement ExAppLogin = driver.FindElement(By.LinkText("test1_decode"));
IWebElement ExAppLogin = driver.FindElement(By.PartialLinkText("test1_decode"));
They all generate an exception "Unable to find Element with xpath =="...