Jump to content

Requesting help in xPath using WebDriverUDF


Recommended Posts

Hello, hope you are doing well :)

I will try to be short and to the point, am trying to automate chrome to do a specific task, i have access to a web page that open another window inside the same parent window (not separated tap), i can successfully automate the steps needed to open that popup. 

the issue here that there is a table inside that popup that am trying to deal with, the table is 4 columns and unknown rows number cause it will be dynamically allocated based on selected parent item. Whatever, am trying to look for specific text inside the third column but am not certain about which row it may exist. 

So, my question is how i can search for this cell using x Path? 

Here is table html code

 

<table id="settings_object_sensor_list_grid" class="table table-bordered table-hover table-responsive dataTable no-footer" role="grid" aria-describedby="settings_object_sensor_list_grid_info" style="width: 100%;">
    <thead>
        <tr role="row" style="height: 0px;">
            <th class="sorting_disabled" rowspan="1" colspan="1" style="width: 222px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;">
                <div class="dataTables_sizing" style="height:0;overflow:hidden;">Name</div>
            </th>
            <th class="sorting_disabled" rowspan="1" colspan="1" style="width: 221px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;">
                <div class="dataTables_sizing" style="height:0;overflow:hidden;">Type</div>
            </th>
            <th class="sorting_disabled" rowspan="1" colspan="1" style="width: 141px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;">
                <div class="dataTables_sizing" style="height:0;overflow:hidden;">Parameter</div>
            </th>
            <th class="sorting_disabled" rowspan="1" colspan="1" style="width: 146px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;">
                <div class="dataTables_sizing" style="height:0;overflow:hidden;">Operations</div>
            </th>
        </tr>
    </thead>
    <tbody>
        <tr role="row" class="odd" id="ACC">
            <td>ACC</td>
            <td>Ignition (ACC)</td>
            <td>di5</td>
            <td><a href="#" onclick="gsSettings.sensorsDialog('244279');" title="Edit"><i class="fa fa-edit fa-lg fa-operations"></i></a><a href="#" onclick="gsSettings.sensorsDelete('244279');" title="Delete"><i class="fa fa-trash-o fa-lg fa-operations"></i></a><a href="#" onclick="gsSettings.sensorsClone('244279');" title="Clone to other objects"><i class="fa fa-trash-o fa-lg fa-clone"></i></a></td>
        </tr>
        <tr role="row" class="even" id="Weight">
            <td>Weight</td>
            <td>WEIGHT</td>
            <td>ai4</td>
            <td><a href="#" onclick="gsSettings.sensorsDialog('244829');" title="Edit"><i class="fa fa-edit fa-lg fa-operations"></i></a><a href="#" onclick="gsSettings.sensorsDelete('244829');" title="Delete"><i class="fa fa-trash-o fa-lg fa-operations"></i></a><a href="#" onclick="gsSettings.sensorsClone('244829');" title="Clone to other objects"><i class="fa fa-trash-o fa-lg fa-clone"></i></a></td>
        </tr>
        <tr role="row" class="odd" id="Volt">
            <td>Volt</td>
            <td>Custom Low High</td>
            <td>ai4</td>
            <td><a href="#" onclick="gsSettings.sensorsDialog('244831');" title="Edit"><i class="fa fa-edit fa-lg fa-operations"></i></a><a href="#" onclick="gsSettings.sensorsDelete('244831');" title="Delete"><i class="fa fa-trash-o fa-lg fa-operations"></i></a><a href="#" onclick="gsSettings.sensorsClone('244831');" title="Clone to other objects"><i class="fa fa-trash-o fa-lg fa-clone"></i></a></td>
        </tr>
        <tr role="row" class="even" id="BATTERY STATUS">
            <td>BATTERY STATUS</td>
            <td>Custom</td>
            <td>di8</td>
            <td><a href="#" onclick="gsSettings.sensorsDialog('245869');" title="Edit"><i class="fa fa-edit fa-lg fa-operations"></i></a><a href="#" onclick="gsSettings.sensorsDelete('245869');" title="Delete"><i class="fa fa-trash-o fa-lg fa-operations"></i></a><a href="#" onclick="gsSettings.sensorsClone('245869');" title="Clone to other objects"><i class="fa fa-trash-o fa-lg fa-clone"></i></a></td>
        </tr>
    </tbody>
</table>

 

Notice here there is a 3button inside the 4th column 


image.thumb.png.4c9023e002e913e195a118876b68f102.png

And am trying to access it using the common _WD_FindElement function. 

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='dialog_settings_object_edit']//table[@id='settings_object_sensor_list_grid']//tr[@id='Volt']")
   
   
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sElement & "//tr[@id='Volt']//td//a[@title='Edit']")

   If @error = $_WD_ERROR_SUCCESS Then
        _WD_ElementAction($sSession, $sElement, 'click')
    EndIf
    
    ConsoleWrite(@error & @CRLF)

 

I hope that i clarified enough, looking for help, thank you. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...