I am testing a calendar component using Selenium. In my test I want to click on the current date. Please help me with the XPath statement for doing that. I am adding the HTML for the calendar component.
<input id="event_date" type="text" on="click then l:show.event.calendar" style="border: 1px solid rgb(187, 187, 187); width: 100px;" fieldset="new_event" decorator="redbox" validator="date"/>
<img id="app_136" style="position: relative; top: 2px;" on="click then l:show.event.calendar" src="images/calendar.png"/>
<div id="app_137" style="margin: 0pt; padding: 0pt;">
<div id="app_calendar_2" class="yui-calcontainer single withtitle" style="position: absolute; z-index: 1000;">
<div class="title">Select Event Date</div>
<table id="app_calendar_2_cal" class="yui-calendar y2010" cellspacing="0">
<thead>
<tr>
</tr>
<tr class="calweekdayrow">
<th class="calweekdaycell">Su</th>
<th class="calweekdaycell">Mo</th>
<th class="calweekdaycell">Tu</th>
<th class="calweekdaycell">We</th>
<th class="calweekdaycell">Th</th>
<th class="calweekdaycell">Fr</th>
<th class="calweekdaycell">Sa</th>
</tr>
</thead>
<tbody class="m6 calbody">
<tr class="w22">
<td id="app_calendar_2_cal_cell0" class="calcell oom calcelltop calcellleft">30</td>
<td id="app_calendar_2_cal_cell1" class="calcell oom calcelltop">31</td>
<td id="app_calendar_2_cal_cell2" class="calcell wd2 d1 selectable calcelltop">
</td>
<td id="app_calendar_2_cal_cell3" class="calcell wd3 d2 today selectable calcelltop selected">
<a class="selector" href="#">2</a>
</td>
I want to click the date component described in
<td id="app_calendar_2_cal_cell3" class="calcell wd3 d2 today selectable calcelltop selected">
<a class="selector" href="#">2</a&g开发者_运维问答t;
</td>
Thanks in advance
mgeorge
How about:
//td[contains(@class, 'today')]/a
Or you could use a CSS locator
css=td.today > a
精彩评论