I have been stuck on trying to click the href="javascript:;" on a page using selenium with python.
The relevant HTML code is:
<tr>
<td class="Sun out">24</td>
<td class=" out">25</td>
<td class=" out">26</td>
<td class=" out">27</td>
<td class=" out">28</td>
<td id="CellPlayDate0" class=" able"><a href="javascript:;" onclick="fnSelectPlayDate(0, '20171229')">29</a></td>
<td id="CellPlayDate1" class=" able"><a href="javascript:;" onclick="fnSelectPlayDate(1, '20171230')">30</a></td>
</tr>
For code, I have:
browser.find_elements_by_xpath('//*[@id="CellPlayDate0"]').click()
The corresponding error message is:
AttributeError: 'list' object has no attribute 'click'
I think that the elements is list, so i tried as below
browser.find_elements_by_xpath('//td[@id="CellPlayDate1"]')[0].click()
However, another error
IndexError: list index out of range
I think there is another method to click a button(javascript,onclick). However, I am the very beginner of selenium, so i have no idea.
Any ideas?