sarmisen / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
0 stars 0 forks source link

How to get table data #115

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi Florent,

I am looking to get all the rows and columns of a table (dynamic) in Excel.
(data can have links as well)

Could you please help.

Thanks in advance.

Regards
Rohit

Original issue reported on code.google.com by rohitkbh...@gmail.com on 14 Nov 2014 at 12:35

GoogleCodeExporter commented 9 years ago
There is many ways to achieve it. 

By using the generic function:
 data = driver.findElementById("tbl1").AsTable.GetData()
 Sheet1.[A1].Resize(UBound(data , 1), UBound(data, 2)).Value = data

By looping over elements:
 For Each row In wd.findElementsByCssSelector("#tableid tr")
   For Each cell in row.findElementsByTagName("td")
       Debug.Print cell.Text
   Next cell
 Next row

By using some JavaScript:
 data = driver.executeScript("return ...")

Original comment by florentbr on 17 Nov 2014 at 10:07