我正在使用Selenium测试日历组件。在我的测试中,我想点击当前日期。请帮我处理XPath声明。我正在为日历组件添加HTML。
<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>
我想点击
中描述的日期组件<td id="app_calendar_2_cal_cell3" class="calcell wd3 d2 today selectable calcelltop selected">
<a class="selector" href="#">2</a>
</td>
提前致谢
mgeorge
答案 0 :(得分:0)
怎么样:
//td[contains(@class, 'today')]/a
或者您可以使用CSS定位器
css=td.today > a