How do I click on the next instance of an element that has the same attributes with another element in Python Selenium?

Viewed 33

I'm trying to click on an element in the same group, that has the same attributes names and values.

I wanna click on the second td tag from this code:

<table id="FolderIcons" class="mstrLargeIconView">
    <tbody>
        <tr>
            <td class="mstrLargeIconView" colspan="1" rowspan="1"></td>
            <td class="mstrLargeIconView" colspan="1" rowspan="1"></td> 
        </tr>
    </tbody>
</table>

I can click on the first element with this code:

wait.until(EC.visibility_of_element_located((By.XPATH,"//td[@rowspan='1']"))).click()

So, How can I click on the second element with the same attribute values?

1 Answers

Try this:

td1=wait.until(EC.visibility_of_element_located((By.XPATH, '//table[@id="FolderIcons"]/tbody/tr[1]/td[1]'))).click()
    
    
td2=wait.until(EC.visibility_of_element_located((By.XPATH, '//table[@id="FolderIcons"]/tbody/tr[1]/td[2]'))).click()
Related