Home > Software design >  How do I click on the next instance of an element that has the same attributes with another element
How do I click on the next instance of an element that has the same attributes with another element

Time:07-21

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" >
    <tbody>
        <tr>
            <td  colspan="1" rowspan="1"></td>
            <td  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?

CodePudding user response:

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