Hello,
How can i scroll to an element with a certain value.
My issue is that i have a table with a list of buttons. I need to click on the button on the middle which has a value. The list can change anytime and the button can change position.
How can i make it click on the same button dynamically.
Please do let me know in case more info is required.
Thanks
@anuradha There are two ways. If you can identify your element with a certain value in a static manner, like text()=‘value’ or id(‘myValue’), then use that. Otherwise you will have to search the table X (across) and Y (down) axis for the “certain value” element. See below for assist on searching web tables:
If you can find the element via static manner it will not matter if the element moves on the page. Similar if you search table and the element has certain value.
Hello There,
Can you help me get the xpath of the below:
What i want to do is click on the button “Choisir”. All the rows have a button Choisir as i see only the value is unique.
What i want to do is click on the button “Choisir” in the table with something static[i think the value is static here] so that whenever my test runs it knows it has to click on this button.
Thanks
You need to use JavaScript:
var d = document.getElementById(“button”);
d.addEventListener(‘click’,function(){
d.className = d.className + " move";
});
Demo: http://jsfiddle.net/LJHQW/3/
Or, if you’re already using jQuery:
$(’.button’).click(function(){
$(this).addClass(‘move’);
});
Demo: http://jsfiddle.net/LJHQW/1/
If you are using KS, you can create a new TestObject and set the attributes as below. When you Save the new element (TestObject), the Selector Editor creates a XPath for you from the list of items that you set to Detect object by?.

You can start with just the value attribute checked or all the attributes checked and adjust if needed.
Hello @helpdesk,
The way you provided above is not making me click on a specific button. There are several “Choisir” button.

The value “Choisir” is for the button but the value which seems unique is “33627” and same goes for the other Choisir button as they will have different numerical values.
I dont want to continue clicking on the first one as there are some information that is needed later in the test case depending on the button being click thats why i want it to click on a specific button and then i will continue the tests on the choice made.
Can you please advise how i can make the xpath for only this value. for example one row can be like this with this information:

and the row numbers can change when adding more information.
Thanks
Although you can see the page, a computer cannot. We give it the information to find every element and it does not matter if the element moves about the page, the computer actually searches for all elements every time.
To find the value, 33627, delete (or uncheck) all the other attributes except for tag and value and change the value attribute to 33627. Then save the changes. The Selector Editor should look something like:
//input[@value=‘33627’]
If the above does not work, an alternative is to add another attribute, XPATH. For that you will type in:
//input[@value=‘Choisir’]/preceding-sibling::input[@value=‘33627’]
If you copy and paste, you will have to change all smart quotes (have a curl or curve to them) to straight quotes.
@helpdesk, how will it know that it needs to click on the ‘Choisir’ button of the value ’ 33627’?
The xpath is selecting the code line which has the value ‘33627’ but not actually selecting the button.
Thanks
@anuradha Sorry. Then we need to start our path from the 33627 element and move to the submit element. Change the XPATH to:
//input[@value=‘33627’]/following-sibling::input[@value=‘Choisir’]
If you copy and paste, you will have to change all smart quotes (have a curl or curve to them) to straight quotes.