RXpath equivalent

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
charlesccorrea
Posts: 3
Joined: Wed Jun 12, 2013 6:36 pm

RXpath equivalent

Post by charlesccorrea » Wed Jun 12, 2013 6:48 pm

I got the following Xpath:

Code: Select all

//div[@class='classname' and .//label[text()='Name']]//li[index]//div[@Id and @data-val-name]//input[@type='text']
I've tried to build an equivalent RxPath to this xpath, but i failed.

Any idea?

Thanks.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: RXpath equivalent

Post by Support Team » Thu Jun 13, 2013 4:10 pm

Hello,

Unfortunately I am not sure what you are trying to do, but if you want to create the path to an element manually I would recommend to use the path editor.
Please read the section "RanoreXPath" in our user guide in order to get more information how to create a valid RanoreXPath.

Regards,
Bernhard
.
Image

charlesccorrea
Posts: 3
Joined: Wed Jun 12, 2013 6:36 pm

Re: RXpath equivalent

Post by charlesccorrea » Thu Jun 13, 2013 5:47 pm

Well, i just want to build a RxPath that returns the same results that this xpath.

Lets do it to be easier to everybody.

1) I need a RxPath that be able to find a div tag like this xpath:

Code: Select all

//div[@class='classname' and .//label[text()='Name']]
.

2) I need a RxPath that find a div tag that contains ANY ID and ANY class name:

Code: Select all

//div[@Id and @classname]


That's it.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: RXpath equivalent

Post by Support Team » Fri Jun 14, 2013 2:30 pm

Hello,

I suspect that every "lable" tag is inside a div tag. Is that right?
You could try to use a path like the following:
//div[@class='classname']//label[@innertext='Name']
The following path can be used for your the second issue.
//div[@id~'.*' and @classname~'.*' ]
Please post a Ranorex Snapshot file in from your application if this is not what you want to do.
Thank you!

Regards,
Bernhard
.
Image

charlesccorrea
Posts: 3
Joined: Wed Jun 12, 2013 6:36 pm

Re: RXpath equivalent

Post by charlesccorrea » Fri Jun 14, 2013 3:49 pm

Hello guys.

The solution for the 2nd issue works fine. Thanks.
The first one, you're right, all labels are inside a div tag, but, it's not "my target element".

Code: Select all

<form>
	<div id="mainDiv">
		<div class="row">
			<div class="header">
				<label for="Status">Status</label>
			</div>
			<div class="value">
				<div id="xx_700645756_905e_4ede_9327_44565461942__xx" name="xx_700645756_905e_4ede_9327_44565461942__xx">
					<div class="anyClassName">
						<div class="buttons">
							<div class="filter"></div>
							<div class="show"></div>
							<div class="new"></div>
						</div>
					</div>
					<div class="input">
						<input id="yy_7456f30_969u_4jd8_5648_3k6jrkd1941"></input>
					</div>
				</div>
			</div>
		</div>
	</div>
</form>
This is my problem. Given a label named "Status", I need to find div tags named "filter", "show" and "new" as well the input tag that has a dynamic Id.

Regards.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: RXpath equivalent

Post by Support Team » Mon Jun 17, 2013 2:19 pm

Hi,

If you want that Ranorex identifies the elements using the class attribute you could change the Path Weight of that attribute.
This will ensure that the class name will be automatically used when you track/record your elements.

In order to change it you have to open the "SETTINGS..." window then you have to click on the "Advanced" tab where you will find the "Edit Path Weights..." button which needs to be clicked in order to open the Editor.
In order to change the value you have to create a new rule where you have to select the "webelement" as capability the "class" as attribute and the value "Set Weight" could be set to 100.
For more details please take a look at the following blog: Automated Testing and Dynamic IDs.

Regards,
Markus
.
Image