there are 32 elements match the RanoreXPath, how do I select 1st element out of 32 elements, thank you in advance
//cell[@columnindex='2']/text[@id='lblLocation' and @caption='Auroa, MN']
Selecting 1st element out of 32
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Selecting 1st element out of 32
Hello,
The following RxPath should select the first element:
Please take a look at RanoreXPath in our User Guide for more information.
Regards,
Markus (T)
The following RxPath should select the first element:
Code: Select all
//cell[@columnindex='2']/text[@id='lblLocation' and @caption='Auroa, MN' and first()='True']
Regards,
Markus (T)
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Selecting 1st element out of 32
Just a follow-up on that topic, since I expect the obvious question to come up shortly: How to select the second, third, ... Xth element?
When you use "FindSingle" or the repository, Ranorex will always get the first element of all elements found for a RanoreXPath. If you want the Xth element, just use an additional index "[X]". The following example selects the 5th element:
Regards,
Alex
Ranorex Team
When you use "FindSingle" or the repository, Ranorex will always get the first element of all elements found for a RanoreXPath. If you want the Xth element, just use an additional index "[X]". The following example selects the 5th element:
Code: Select all
//cell[@columnindex='2']/text[@id='lblLocation' and @caption='Auroa, MN'][5]
Alex
Ranorex Team
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Selecting 1st element out of 32
You are welcome!
Regards,
Alex
Regards,
Alex
Re: Selecting 1st element out of 32
My mistake, it was not clickable after finding the 1st element, I do need to click on 'btnCan' After finding the 1st element(Saukaripds, MN) out of 32 element
//row[@index='3']/cell/table/row/cell[@text='xyz ']/button[@id='btnCan']
this button resides on previous cell of the 1st Element that found
Thank you.
//row[@index='3']/cell/table/row/cell[@text='xyz ']/button[@id='btnCan']
this button resides on previous cell of the 1st Element that found
Thank you.
You do not have the required permissions to view the files attached to this post.
Tipu
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Selecting 1st element out of 32
I guess you'll need a RanoreXPath that retrieves you the sibling cell. The following documentation and resources should help you in finding the correct RanoreXPath:
http://www.ranorex.com/forum/how-do-i-g ... html#p6326
http://www.ranorex.com/support/screencasts.html#c2669
http://www.ranorex.com/support/user-gui ... html#c3296
Regards,
Alex
Ranorex Team
http://www.ranorex.com/forum/how-do-i-g ... html#p6326
http://www.ranorex.com/support/screencasts.html#c2669
http://www.ranorex.com/support/user-gui ... html#c3296
Regards,
Alex
Ranorex Team
Re: Selecting 1st element out of 32
Thank you Alex, Here is the code that working for me
Code: Select all
SmartSearchPage.ClickOnCellButton(smartSearch.FindSingle(".//cell[@columnindex='2']/text[@id='lblLocation' and @caption='"+firstCityAndState+"'and first()='True']"));
#region| After matching the search result in Second Column(Eden, MN), then Click on Name at 1st Column
public static void ClickOnCellButton(Ranorex.FlexElement text)
{
string rxPath = text.GetPath().ToString();
Unknown newRxPath = rxPath.Replace("/cell[@columnindex='2']/text[@id='lblLocation']", "/cell[@columnindex='1']");
newRxPath.Click();
}
#endregion
Tipu
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Selecting 1st element out of 32
A small follow-up on that topic: You could also use the ".." parent operator and the "preceding-sibling" axis to achieve the same result:
Regards,
Alex
Ranorex Team
Code: Select all
//cell[@columnindex='2']/text[@id='lblLocation' and @caption='Auroa, MN'][5]/../preceding-sibling::cell
Alex
Ranorex Team