Reputation: 209
I'm using selenium and i found this web element :
<td style="padding-right: 10px; " **onclick="javascript:show_me('CarDetails.php?CarID=2358912&SubCatID=1**', '2358912', 560, 'ActiveLinkVisited');stat( '../', 176, '', '' );" id="Txt_2358912">blabla</td>
I want to grab the "onclick"
attribute information (the javascript:show
... text).
How can i do it with selenium (like the attr
function in DOM
).
Thanks,
Or.
Edit : I will clarify my question. I have something like this :
<tr id="tr_2358912" class="ActiveLink" onmouseover="this.className='overActiveLink'" onmouseout="(document.getElementById("TxtID2358912").innerText!="bla") ? this.className="ActiveLink" : this.className="openActiveLink" ">
<td valign="middle">
<td width="2"/>
<td id="Txt_2358912" onclick="javascript:show_me('CarDetails.php?CarID=2358912&SubCatID=1', '2358912', 560, 'ActiveLinkVisited');stat( '../', 176, '', '' );" style="padding-right: 7px; ">Text Here</td>
<td width="2"/>
And I have a WebElement that contains the ActiveLink class :
WebElement element = driver.findElement(By.className("ActiveLink"));
I want from the elements object get the onclick value
("javascript:show_me('CarDetails.php?CarID=2358912&SubCatID=1', '2358912', 560, 'ActiveLinkVisited'").
I tried with
element.findElement(By.xpath("//td[@onclick]")).getText()
And tried alot more.. but with no success.
I'm kind of new with this..
I hope that someone can help me..
Thanks!
Upvotes: 1
Views: 2858
Reputation: 5667
String onclick=selenium.getAttribute("//td[contains(@onclick,'CarDetails.php')]@onclick");
onclick=onclick.substring(onclick.indexOf(":")+1)
Upvotes: 2
Reputation: 457
Try this using the attribute selector:
selector=//selector/used/to/find/the/td/@onclick
Upvotes: 1