Reputation: 3534
I am trying to select multiple elements using xpath in Selenium IDE. The query i am using is
//*[contains(@id, "address_menu_")]
This works for the first element, but there are 8 on the screen that I am trying to target. Any thoughts? Thanks.
*Edit - here is the HTML copied over from Firebug. I extended the product, but the left the other ones minimized for space. The first four products are gift announcements (the functionality I am testing)) and the last 4 are actual products. For the record, what I am trying to target is -
<td class="item-address">
<select id="address_menu_71740515" name="address_71740515">
<script type="text/javascript">
<tr id="item_71740515" class=" odd gift_cont">
<th class="sub">
<td class="product">1 x Gift Announcement (Physical)</td>
<td>
<td class="item-address">
<select id="address_menu_71740515" name="address_71740515">
</td>
<td class="price">$0.00</td>
<td class="price">$0.00</td>
</tr>
<tr class="gift_sep">
<script type="text/javascript">
<tr id="item_71740511" class=" gift_cont">
<tr class="gift_sep">
<script type="text/javascript">
<tr id="item_71740507" class=" odd gift_cont">
<tr class="gift_sep">
<script type="text/javascript">
<tr id="item_71740503" class=" gift_cont">
<tr class="gift_sep">
<tr id="item_71740495" class=" odd">
<tr id="item_71740487" class=" ">
<tr id="item_71740499" class=" odd">
<tr id="item_71740491" class=" ">
Upvotes: 1
Views: 4176
Reputation: 1
You can use:
<tr>
<td>addSelection</td>
<td>Locate your select element</td>
<td>Option you need to select</td>
</tr>
Upvotes: 0
Reputation: 4470
Actually it is not possible to do this way in Selenium. Many of its commands intended to work with exact one element. Although you can do it another way, just clarify your question what do you need exactly?
Now it seems that I understood what you are doing. You have selects
inside <td>
.
//*[contains(@id, "address_menu_")][1]
allows to select only from siblings, but your selects are obviously not those.
If you have all of them in one table then you can slightly change expression, e.g.:
//tr[contains(@id, 'item_')][1]/descendant::select
//tr[contains(@id, 'item_')][2]/descendant::select
Upvotes: 1