我在Python中使用Selenium,但遇到了一些问题。 在网站上,有一个日历,用户必须手动单击日期。
我的问题是我想单击带有硒代码(.click())的特定日期。 我还没有找到选择日期(例如27号)并允许Selenium单击它的方法。
感谢您的帮助!
以下html代码以下:
<div class="calendar" style="display: block; top: 515.667px; left: 50px;">
<div class="month dual">
<div class="wrapper">
<header>
<span class="prev arrow" style="display: none;">
<span class="icons-arrow_black_left"></span>
<span class="next arrow" style="display: none;"></span>
<span class="icons-arrow_black_right"></span>
<h1 data-automation-id="12">Décembre 2019</h1>
</header>
<table class="body" cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<th>D</th>
<th>L</th>
<th>M</th>
<th>M</th>
<th>J</th>
<th>V</th>
<th>S</th>
</tr>
<div class="calendar" style="display: block; top: 515.667px; left: 50px;">
<div class="month dual">
<div class="wrapper">
<header>
<span class="prev arrow" style="display: none;">
<span class="icons-arrow_black_left"></span>
<span class="next arrow" style="display: none;"></span>
<span class="icons-arrow_black_right"></span>
<h1 data-automation-id="12">Décembre 2019</h1>
</header>
<table class="body" cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<th>D</th>
<th>L</th>
<th>M</th>
<th>M</th>
<th>J</th>
<th>V</th>
<th>S</th>
</tr>
<tr>
<td class>1</td>
<td class>2</td>
<td class>3</td>
<td class>4</td>
<td class>5</td>
<td class>6</td>
<td class>7</td>
</tr>
<tr>
<td class>8</td>
<td class>9</td>
<td class>10</td>
<td class>11</td>
<td class>12</td>
<td class>13</td>
<td class>14</td>
</tr>
<tr>
<td class>15</td>
<td class>16</td>
<td class>17</td>
<td class>18</td>
<td class>19</td>
<td class>20</td>
<td class>21</td>
</tr>
<tr>
<td class>22</td>
<td class>23</td>
<td class>24</td>
<td class>25</td>
<td class>26</td>
<td class>27</td>
<td class>28</td>
</tr>
<tr>
<td class>29</td>
<td class>30</td>
<td class>31</td>
答案 0 :(得分:0)
您可以尝试:
xpath = '//table/tbody/tr[5]/td[6]'
每月27号