我有一个Jquery日历,它显示了一周的工作日,还显示了哪些天是活跃的(即周末天没有活动,以及过去的日子都没有活动)
我想知道是否有人知道从哪里开始使用seleiumn webdriver如何在jquery日历中选择活跃的一天
下面是我正在尝试为
编写测试的日历代码 <DIV CLASS="hasDatepicker" ID="txtDate"><DIV CLASS="ui-datepicker-inline ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"
STYLE="display: block;"><DIV CLASS="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all"><A CLASS="ui-datepicker-prev ui-corner-all ui-state-disabled"
TITLE="Prev"><SPAN CLASS="ui-icon ui-icon-circle-triangle-w">Prev</SPAN></A><A CLASS="ui-datepicker-next ui-corner-all" DATA-EVENT="click" DATA-HANDLER="next"
TITLE="Next"><SPAN CLASS="ui-icon ui-icon-circle-triangle-e">Next</SPAN></A><DIV CLASS="ui-datepicker-title"><SPAN CLASS="ui-datepicker-month">June</SPAN> ?<fw<SPAN CLASS="ui-datepicker-year">2014</SPAN></DIV>
</DIV>
<TABLE CLASS="ui-datepicker-calendar">
<THEAD>
<TR>
<TH CLASS="ui-datepicker-week-end"><SPAN TITLE="Sunday">Su</SPAN></TH>
<TH><SPAN TITLE="Monday">Mo</SPAN></TH>
<TH><SPAN TITLE="Tuesday">Tu</SPAN></TH>
<TH><SPAN TITLE="Wednesday">We</SPAN></TH>
<TH><SPAN TITLE="Thursday">Th</SPAN></TH>
<TH><SPAN TITLE="Friday">Fr</SPAN></TH>
<TH CLASS="ui-datepicker-week-end"><SPAN TITLE="Saturday">Sa</SPAN></TH>
</TR>
</THEAD>
<TBODY>
<TR>
<TD CLASS=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">1</SPAN></TD>
<TD CLASS=" ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">2</SPAN></TD>
<TD CLASS=" ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">3</SPAN></TD>
<TD CLASS=" ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">4</SPAN></TD>
<TD CLASS=" ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">5</SPAN></TD>
<TD CLASS=" ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">6</SPAN></TD>
<TD CLASS=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">7</SPAN></TD>
</TR>
<TR>
<TD CLASS=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">8</SPAN></TD>
<TD CLASS=" ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">9</SPAN></TD>
<TD CLASS=" ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">10</SPAN></TD>
<TD CLASS=" ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">11</SPAN></TD>
<TD CLASS=" ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">12</SPAN></TD>
<TD CLASS=" ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">13</SPAN></TD>
<TD CLASS=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">14</SPAN></TD>
</TR>
<TR>
<TD CLASS=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">15</SPAN></TD>
<TD CLASS=" ui-datepicker-unselectable ui-state-disabled undefined ui-datepicker-today"><SPAN CLASS="ui-state-default">16</SPAN></TD>
<TD CLASS=" ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">17</SPAN></TD>
<TD CLASS=" ui-datepicker-days-cell-over undefined"
DATA-EVENT="click" DATA-HANDLER="selectDay" DATA-MONTH="5"
DATA-YEAR="2014"><A CLASS="ui-state-default" HREF="#">18</A></TD>
<TD CLASS=" undefined" DATA-EVENT="click"
DATA-HANDLER="selectDay" DATA-MONTH="5" DATA-YEAR="2014"><A CLASS="ui-state-default"
HREF="#">19</A></TD>
<TD CLASS=" undefined" DATA-EVENT="click"
DATA-HANDLER="selectDay" DATA-MONTH="5" DATA-YEAR="2014"><A CLASS="ui-state-default"
HREF="#">20</A></TD>
<TD CLASS=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">21</SPAN></TD>
</TR>
<TR>
<TD CLASS=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">22</SPAN></TD>
<TD CLASS=" undefined" DATA-EVENT="click"
DATA-HANDLER="selectDay" DATA-MONTH="5" DATA-YEAR="2014"><A CLASS="ui-state-default"
HREF="#">23</A></TD>
<TD CLASS=" undefined" DATA-EVENT="click"
DATA-HANDLER="selectDay" DATA-MONTH="5" DATA-YEAR="2014"><A CLASS="ui-state-default"
HREF="#">24</A></TD>
<TD CLASS=" undefined" DATA-EVENT="click"
DATA-HANDLER="selectDay" DATA-MONTH="5" DATA-YEAR="2014"><A CLASS="ui-state-default"
HREF="#">25</A></TD>
<TD CLASS=" undefined" DATA-EVENT="click"
DATA-HANDLER="selectDay" DATA-MONTH="5" DATA-YEAR="2014"><A CLASS="ui-state-default"
HREF="#">26</A></TD>
<TD CLASS=" undefined" DATA-EVENT="click"
DATA-HANDLER="selectDay" DATA-MONTH="5" DATA-YEAR="2014"><A CLASS="ui-state-default"
HREF="#">27</A></TD>
<TD CLASS=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">28</SPAN></TD>
</TR>
<TR>
<TD CLASS=" ui-datepicker-week-end ui-datepicker-unselectable ui-state-disabled undefined"><SPAN CLASS="ui-state-default">29</SPAN></TD>
<TD CLASS=" undefined" DATA-EVENT="click"
DATA-HANDLER="selectDay" DATA-MONTH="5" DATA-YEAR="2014"><A CLASS="ui-state-default"
HREF="#">30</A></TD>
<TD CLASS=" ui-datepicker-other-month ui-datepicker-unselectable ui-state-disabled"> ?<fw</TD>
<TD CLASS=" ui-datepicker-other-month ui-datepicker-unselectable ui-state-disabled"> ?<fw</TD>
<TD CLASS=" ui-datepicker-other-month ui-datepicker-unselectable ui-state-disabled"> ?<fw</TD>
<TD CLASS=" ui-datepicker-other-month ui-datepicker-unselectable ui-state-disabled"> ?<fw</TD>
<TD CLASS=" ui-datepicker-week-end ui-datepicker-other-month ui-datepicker-unselectable ui-state-disabled"> ?<fw</TD>
</TR>
</TBODY>
</TABLE>
我已经尝试过并使用了以下代码,但觉得这让我无处可去,因为我必须对日期进行硬编码。
IWebElement dateWidget = WebDriver.FindElement(By.Id("txtDate"))
IList<IWebElement> rows = dateWidget.FindElement(By.TagName("tr"));
IList<IWebElement> columns = dateWidget.FindElement(By.TagName("td"));
for (IWebElement cell in columns)
{
if(cell.Text.Equals("13") && cell.FindElement(By.CssSelector("#txtDate > div > table > tbody > tr:nth-of-type(2) > td:nth-of-type(1)")))
{
cell.FindElement(By.LinkText("13")).Click();
}
}