I'm working on some Selenium/Robot Framework automated testing, and I need a way to automate locating div
tags that are clickable.
The Click Element keyword does the trick if I give it a very specific CSS selector, but how can I algorithmically find an element that can be clicked? As long as there is a way to get the DOM node, I'm hoping to return a unique selector that I can use to call the Click Element keyword.
I understand that old versions of jQuery have $(element).data('events')
that might be used to find click listeners, but it seems like an unreliable method. Moreover, the Chrome web inspector doesn't seem to recognize any click
listeners for the div
s that I'm looking at.
For completeness, here is an example of the HTML I'm working with:
<div id="contentarea" class="">
<div id="contentwrapper" style="opacity: 1;">
<div class="rap">
<div id="twocol" class="clearfix margintop">
<div class="leftcol scrollable addprogram">
<a href="..." class="newgroup">
<span class="addicon"></span>New Group
</a>
</div>
<div class="rightcol clearfix">
<ul class="subtabs rounded clearfix">
<li data-tab="pending" class="selected">
<a href="..." class="selected">Released</a>
</li>
</ul>
<div class="clear"></div>
<div id="program-grid" class="clearfix" style="">
<div class="program groups" tabindex="0">
<div class="programframe"></div>
<div class="programinfo">
<h1 class="prizeheight">Development</h1>
</div>
</div><div class="program groups" tabindex="0">
<div class="programframe"></div>
<div class="programinfo">
<h1 class="prizeheight">Loss Prevention/Safety Group</h1>
</div>
...
...
<div class='program groups'>
is a clickable element that I hope to identify programmatically.
For the record, the HTML is valid and so on. Minified Javascript somehow renders this source, and probably attaches the listeners.
Thanks!