Search code examples
rubyhtml-tablewatirrubyminepageobjects

Watir iterating through a table to find a specific row


I need to be able to search through this table and find a specific row using the title of it. (I want to find the row which I have shown in the code below):

<table class="no-btm-margin">
    <colgroup></colgroup>
    <thead></thead>
    <tbody>
        <tr></tr>
        <tr></tr>
        <tr>
            <td>
                <span class="vac-title">Test Vacancy 958075
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td>
                <a href="/vacancy/review?vacancyReferenceNumber=525">Review vacancy</a>
            </td>
        </tr>
        <tr></tr>
        <tr></tr>

I then need to go across the row to the last column and click the link. Could someone please give me an example of a method which would work to do this.


Solution

  • I fixed it by using:

    table(:dashboard, :class => 'no-btm-margin')
    

    The above code just allows to to call the table using the keyword dashoard

    dashboard_element['Test Vacancy 958075'][6].click
    

    This worked for me hopefully it works for you