Search code examples
c#watin

How to select a table with no ID or class


Clarification - I'm using Watin to automate the browser. It's a Watin Table object I need to create, not a javascript object.

I'm using watin to extract data from a web app. I need to create a watin Table but the table in the html has neither an ID nor a class.

It is nested in another table though, inside a div which has an id of detailsDiv.

<div id="detailsDiv">
    <table>
        <tbody>
            <table> <!-- This is the table I need to get to-->

            </table>
        </tbody>    
    </table>
</div>

Is there a way I can create an object from that table without the id or class?


Solution

  • So here is what I've managed to come up with. May help someone else in the future:

    Div detailsDiv = ie.Div("detailsDiv");
    
    TableCollection tableColl = detailsDiv.Tables;
    Table featuresTable = tableColl[1];