problem in parameterizing the element definition(x-path)

Ranorex Spy, Recorder, and Studio.
Shruti
Posts: 25
Joined: Thu Sep 06, 2012 9:13 am

problem in parameterizing the element definition(x-path)

Post by Shruti » Mon Oct 08, 2012 11:16 am

Hi All,

I am facing a problem in parameterizing the element definition(x-path).

The X-path I am using is :
.//ul[#'CurrentTags']/li/span[$var_tagnumber]

Here, Variable var_tagnumber is bound to a CSV file.
And I am proving the span index(1,2,3, etc.) through this variable.
ie. the values in CSV are as:

TagIndex
1
2
3
4
5
6


The problem is: at runtime, the X-path is genertaed as:

.//ul[#'CurrentTags']/li/span['2']
(checking for Span tag with label 2)

while I am looking for

.//ul[#'CurrentTags']/li/span[2]
(span tag with index 2)


Could anybody please suggest me asap if there is some solution to this problem?


Thanks and Regards,
Shruti Singh

sham526
Posts: 34
Joined: Wed Jul 07, 2010 7:12 am
Location: Hyderabad(INDIA)

Re: problem in parameterizing the element definition(x-path)

Post by sham526 » Mon Oct 08, 2012 1:09 pm

=
Last edited by sham526 on Mon Oct 08, 2012 1:11 pm, edited 1 time in total.

sham526
Posts: 34
Joined: Wed Jul 07, 2010 7:12 am
Location: Hyderabad(INDIA)

Re: problem in parameterizing the element definition(x-path)

Post by sham526 » Mon Oct 08, 2012 1:10 pm

Instead u can Try

.//ul[#'CurrentTags']/li/span['$var_tagnumber$']

sham526
Posts: 34
Joined: Wed Jul 07, 2010 7:12 am
Location: Hyderabad(INDIA)

Re: problem in parameterizing the element definition(x-path)

Post by sham526 » Mon Oct 08, 2012 1:12 pm

Hi Shruthi try the below (in Vb.Net)

Dim li_each As LiTag = Nothing
Dim bool As Boolean = Host.Local.TryFindSingle(".//ul[#'CurrentTags']/li", li_each)
If bool Then
'Now search for the Span Tag with the index from CSV File
Dim span_each As SpanTag = li_each.FindSingle(Of SpanTag)("./span[@childindex='" & var_tagnumber. ToString & "']")
End If

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

Re: problem in parameterizing the element definition(x-path)

Post by Support Team » Mon Oct 08, 2012 1:52 pm

Hi Shruti,

Is this the RxPath of a repo item or are you using this RxPath in UserCode?
By the way which Ranorex version are you using?

Regards,
Markus
Ranorex Support Team
.
Image

Shruti
Posts: 25
Joined: Thu Sep 06, 2012 9:13 am

Re: problem in parameterizing the element definition(x-path)

Post by Shruti » Mon Oct 08, 2012 9:46 pm

Hi,
I am using Ranorex 3.3.2(extended trail version).
I am using RxPath of repo item not code(and I would like to avoid coding as much as possible)


Thanks and Regards,
Shruti

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

Re: problem in parameterizing the element definition(x-path)

Post by Support Team » Tue Oct 09, 2012 3:52 pm

Hi,

Then it should work, you can use one of the two RxPaths in order to identify the element with the specific index saved in the variable:
YourRxPath/span[$indexvariable]
//OR
YourRxPath/span[index()=$indexvariable]
as described in the following UserGuide section: RanoreXPath.

Regards,
Markus
Ranorex Support Team
.
Image

Shruti
Posts: 25
Joined: Thu Sep 06, 2012 9:13 am

Re: problem in parameterizing the element definition(x-path)

Post by Shruti » Thu Oct 11, 2012 10:31 am

yes..it's working now..
I guess I wasn't using it correctly.

Thanks
Shruti

Shruti
Posts: 25
Joined: Thu Sep 06, 2012 9:13 am

Re: problem in parameterizing the element definition(x-path)

Post by Shruti » Sat Aug 31, 2013 1:39 pm

Hi All,

I am facing a problem in parameterizing the browser URL value based on testcase.

In an excel file i have the following fields
Testcasename URLvalue
Actitivity1.01 abc.com
Actitivity1.02 google.com

The problem is: how to bind this data with my testsuite so that for first testcase it launch abc.com, run checks mentioned in activity1.01.
Launch second testcase it should launch google.com


Thanks,
Shruti

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

Re: problem in parameterizing the element definition(x-path)

Post by Support Team » Mon Sep 02, 2013 4:21 pm

Hello Shruti,

You can use the same file as data source in each test case and only set the data range in the specific data connector.
Please read the section "Data Connectors" in our user guide in order to get more information where to use this setting.

Regards,
Bernhard
.
Image