Variable for RxPath from Excel

Class library usage, coding and language questions.
Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Variable for RxPath from Excel

Post by Hermch » Wed May 23, 2012 10:29 am

Hi,

how can I read out the value for a RxPath from an excel document properly?

I tried the following:

Code: Select all


'Module variable for the repository item to compare the screenshot with
        Dim _RepoPath As String
        <TestVariable("3BBF473C-2916-4189-997E-047A84105538")> _
        Public Property RepoPath As String
        	Get
        		Return _RepoPath
        	End Get
        	Set(ByVal value As String)
        		_RepoPath = value
        	End Set
        End Property

Dim CapturedImage As Bitmap = Imaging.CaptureImage(RepoPath)


My testcase fails and the report says:

Invalid RxPath 'repo.WebDocumentBDT_BaseLine.Service.Img_ServicePage'. Invalid character at character position 4.

If I do it with the path instead of the variable, the test passes:

Code: Select all

Dim CapturedImage As Bitmap = Imaging.CaptureImage(repo.WebDocumentBDT_BaseLine.Service.Img_ServicePage)

Why does the test fail if I use my "RepoPath" variable?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Variable for RxPath from Excel

Post by Support Team » Wed May 23, 2012 10:43 am

Hi,

basically, you have to create an element, you can capture an image from.

Therefore you have to set the value of your variable to the RanoreXPath of the UI element you want to capture the screenshot from.
Please have a look at follwoing chapter of our user guide to learn more about the RanoreXPath:
http://www.ranorex.com/support/user-gui ... xpath.html

After doing so you have to create an Ranorex.Element using the RanoreXPath stored in your variable and capture an image from this element.

Code: Select all

Dim el As Element = RepoPath
Imaging.CaptureImage(el)
Regards,
Tobias
Ranorex Team

Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Re: Variable for RxPath from Excel

Post by Hermch » Wed May 23, 2012 12:27 pm

Ok, but I still don't understand why it works with this code:

Version 1:

Code: Select all


Dim CapturedImage As Bitmap = Imaging.CaptureImage(repo.WebDocumentBDT_BaseLine.Service.Img_ServicePage)

Here I do not capture the Image by the RxPath but by the Repo path.

And it does not work with this code:

Version 2:

Code: Select all


Dim CapturedImage As Bitmap = Imaging.CaptureImage(RepoPath)

Inside the variable "RepoPath" is the same path: repo.WebDocumentBDT_BaseLine.Service.Img_ServicePage
but it is called from an excel file.


Can you please explain me why Version 1 works, while Version 2 does not?
My point is, that I would like to read a repository path like: repo.WebDocumentBDT_BaseLine.Service.Img_ServicePage
from the excel file and capture the image by this repository path.
Last edited by Hermch on Wed May 23, 2012 12:48 pm, edited 1 time in total.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Variable for RxPath from Excel

Post by Support Team » Wed May 23, 2012 12:48 pm

Hi,
Support Team wrote:Can you please explain me why Version 1 works, while Version 2 does not?
As mentioned before, please have a look at the RanoreXPath docu.
The path you are using is the code based reposiotry hierarchy, and not the ranoreXPath of the element.

With binding the var to a valid RanoreXPath value, you should not have any porblems with capturing an image.


Regards,
Tobias
Ranorex Team

Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Re: Variable for RxPath from Excel

Post by Hermch » Wed May 23, 2012 1:05 pm

OK thanks