选择datepicker元素Selenium Web Driver

时间:2015-12-12 16:26:39

标签: java selenium datepicker

我尝试在Selenium 2 Web Driver中选择日期表单datepicker下拉菜单。到目前为止,我还没有找到解决问题的方法。

我在Selenium 2 Java中编程。

我正在测试的网页是http://intercity.pl 这是我试图从中选择的HTML:

<div class="datepicker datepicker-dropdown dropdown-menu" style="display:  block; left: 1097px; top: 34.5px;">
    <div class="datepicker-days" style="display: block;">
        <table class=" table-condensed">
            <thead>
                <tr>
                    <th class="prev" style="visibility: visible;">«</th>
                    <th class="datepicker-switch" colspan="5">Grudzień 2015</th>
                    <th class="next" style="visibility: visible;">»</th>
                </tr>
                <tr>
                    <th class="dow">Pn</th>
                    <th class="dow">Wt</th>
                    <th class="dow">Śr</th>
                    <th class="dow">Cz</th>
                    <th class="dow">Pt</th>
                    <th class="dow">So</th>
                    <th class="dow">N</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="old day">30</td>
                    <td class="day">1</td>
                    <td class="day">2</td>
                    <td class="day">3</td>
                    <td class="day">4</td>
                    <td class="day">5</td>
                    <td class="day">6</td>
                </tr>
                <tr>
                <tr>
                <tr>
                <tr>
                <tr>
            </tbody>
            <tfoot>
        </table>
    </div>
    <div class="datepicker-months" style="display: none;">
        <table class="table-condensed">
            <thead>
            <tbody>
                <tr>
                    <td colspan="7">
                        <span class="month">Sty</span>
                        <span class="month">Lu</span>
                        <span class="month">Mar</span>
                        <span class="month">Kw</span>
                        <span class="month">Maj</span>
                        <span class="month">Cze</span>
                        <span class="month">Lip</span>
                        <span class="month">Sie</span>
                        <span class="month">Wrz</span>
                        <span class="month">Pa</span>
                        <span class="month">Lis</span>
                        <span class="month active">Gru</span>
                    </td>
                </tr>
            </tbody>
            <tfoot>
        </table>
    </div>
    <div class="datepicker-years" style="display: none;">
        <table class="table-condensed">
            <thead>
            <tbody>
                <tr>
                    <td colspan="7">
                        <span class="year old">2009</span>
                        <span class="year">2010</span>
                        <span class="year">2011</span>
                        <span class="year">2012</span>
                        <span class="year">2013</span>
                        <span class="year">2014</span>
                        <span class="year active">2015</span>
                        <span class="year">2016</span>
                        <span class="year">2017</span>
                        <span class="year">2018</span>
                        <span class="year">2019</span>
                        <span class="year new">2020</span>
                    </td>
                </tr>
            </tbody>
            <tfoot>
        </table>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

我已经找到了解决方案。我没有点击日期选择器,而是将键发送到输入字段。