user3033194
user3033194

Reputation: 1821

Element not being located by Xpath

I am trying to click on a button in a table row. The relevant HTML code is given below:

<div id="catalogItems" class="col-xs-12">
...
    <table class="table table-condensed table-hover">
        ...
        <tbody id="existingItemsList">
            <tr id="item_3" class="info item" item_name="vegetables" role="form" item_id="3">
                ...
            </tr>
            <tr id="item_4" class="info item" item_name="pizza" role="form" item_id="4">
                ...
            </tr>
            <tr id="item_5" class="info item" item_name="Pastries" role="form" item_id="5">
                <td>
                    <button onclick=".." class="btn btn-sm btn-info" type="button"><i class="fa fa-times"></i></button>
                </td>
            </tr>
            <tr id="item_6" class="info item" item_name="Burger" role="form" item_id="6">
         ...

I want to access the the button in the row with item_name="pastries" to run a test on it with Robot. My Xpath is given below:

xpath=//div[@id='catalogItems']//tr[@item_name=Pastries]//button[@class='btn btn-sm btn-info']

With this, however, the button in the first row (item_name="vegetables") is being selected by the Robot FW. How should I change the xpath to access the item_name="pastries" row? Please help!

Upvotes: 1

Views: 84

Answers (1)

Dmytro Pastovenskyi
Dmytro Pastovenskyi

Reputation: 5419

I think this is because you have an issue here, please cover Pastries with '', so it looks like 'Pastries'

//tr[@item_name='Pastries']

Upvotes: 3

Related Questions