Using XPath preceding-sibling correctly

0 votes

Below is the code I wrote using Selenium IDE. Problem is with the clicking on a button using preceding-sibling

<td>

<div class="btn-group">

<button class="btn btn btn-danger block" title="Warning, Delete" name="delete" type="button">

<button class="btn btn btn-default block" title="View History" name="history" type="button">

<button class="btn btn btn-default block" title="View Settings" name="settings" type="button">

<button class="btn btn btn-default block" name="device" type="button">

<span class="glyphicon glyphicon-pencil"/>

 Arcade Reader

</button>

</div>

</td>

My path

xpath=//button[contains(.,'Arcade Reader')]/../preceding-sibling::button[@name='settings']

Apr 18, 2018 in Selenium by Martin
• 4,210 points
2,256 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Since all buttons are on the same level you don't need to go level up and use

Use below code:

//button[contains(.,'Arcade Reader')]/preceding-sibling::button[@name='settings']

answered Apr 18, 2018 by Vardy
• 2,280 points

Related Questions In Selenium

0 votes
1 answer

How to get next sibling element using XPath and Selenium for Java?

Below code will help you: Try following-sibling axis : WebElement ...READ MORE

answered May 15, 2018 in Selenium by Samarpit
• 5,130 points
3,669 views
0 votes
1 answer

preceding-sibling in xpath, Selenium?

Here, ul has 8 children(8-li) on total.  And, ...READ MORE

answered Jun 1, 2018 in Selenium by Vinita
• 220 points
939 views
0 votes
1 answer

Returning null element when using following and preceding XPath selector

To identify the <input> tag with respect to the <label> tag ...READ MORE

answered Jun 8, 2018 in Selenium by Samarpit
• 5,130 points
44 views
0 votes
1 answer

Using XPath with Selenium-Java code

There is a minor syntax error in ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,590 points
33 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,030 points
51 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
409 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
40 views
0 votes
1 answer
0 votes
1 answer

JavaScript Executor using Selenium WebDriver

Its working fine but the problem in ...READ MORE

answered Apr 9, 2018 in Selenium by Vardy
• 2,280 points
144 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.