S
S
Sheryorg2015-03-02 11:13:01
Python
Sheryorg, 2015-03-02 11:13:01

How to copy a table using selenium?

Please tell me how to copy a table using selenium.
Table example:

<table class="users">
    <tr class="new">
        <td>1</td>
    </tr>
   .....
</table>

I find the element by class, but I can't copy the content into an array.
Finally, the table must be saved to a file.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sheryorg, 2015-03-03
@Sheryorg

I solved the issue by iterating over the rows of the table using xpath.

while k < 10:
            try:
                new_users = driver.find_element_by_xpath('//*[@id="new"]/div/table[2]/tr['+str(k)+']').text
                list.append(new_users+'\n')
            except:
                pass
            j += 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question