Skip to content
Advertisement

How to get all tr id by using python selenium?

<table id="tbl-orderNumber" class="ui-jqgrid-btable">
    <tbody>
        <tr class = "jqgfirstrow"></tr>
        <tr id ="AAAA"></tr>
        <tr id ="BBBB"></tr>
        <tr id ="CCCC"></tr>
    </tbody>
</table>

i have try but not work. Cannot get all id of tr AAAA, BBBB, CCCC. Thanks

driver.find_elements(By.CSS_SELECTOR, 'tbl-orderNumber')

Advertisement

Answer

I prefer to use xpath to do the all things:

for row in driver.find_elements_by_xpath('//table[@id="tbl-orderNumber"]//tr'):
    print(row.get_attribute('id'))
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement