Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Testing Selenium测试的XPath语句需要帮助_Testing_Scripting_Xpath_Selenium - Fatal编程技术网

Testing Selenium测试的XPath语句需要帮助

Testing Selenium测试的XPath语句需要帮助,testing,scripting,xpath,selenium,Testing,Scripting,Xpath,Selenium,我正在使用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" valida

我正在使用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>

选择事件日期
苏
钼
屠
我们
Th
Fr
Sa
30
31
我想单击中描述的日期组件

<td id="app_calendar_2_cal_cell3" class="calcell wd3 d2 today selectable calcelltop selected">
<a class="selector" href="#">2</a>
</td>

提前谢谢

mgeorge如何:

//td[contains(@class, 'today')]/a
或者您可以使用CSS定位器

css=td.today > a

好听的,一般来说CSS定位器在速度和跨浏览器兼容性方面更好。嗨,为什么CSS定位器比XPath定位器更好?有经验的浏览器不是为XPath表达式设计的,谢谢