Page 1 of 1

Problem with guid in URL

Posted: Tue Mar 03, 2015 7:19 pm
by smp245
Hello,
I hope someone will be able to help me with this problem. Here goes...

Each time I open an input form a new guid is genereated.
Is it possible, and if so, how do I capture the newly genereated guid from the newly opened web page and then use that guid for the inputting of data into the fields within the form.

Here is the repository entry for one of the fields:
div[2]/div/div[4]//iframe[@src='/myForms/myContact.aspx?OBJID=-1&CompanyID=1234567890&guid=229B12F2-45B0-4705-A942-143D1E44B4DD']//input[#'Firstname]

Many thanks for any help you can offer.

Re: Problem with guid in URL

Posted: Tue Mar 03, 2015 8:05 pm
by krstcs
When raising an issue or a question in the forums, please include the following information:
1. Version of Ranorex
2. Version of Windows
3. Technology of System Under Test (Flash/Flex, HTML, Java, WPF, WinForms, etc.) - You indicated a web page, but didn't specify the underlying technology.
4. If applicable, the text of any error messages.

Also, please include a Ranorex Snapshot of the SUT along with any RanoreXPaths that you have questions about. You can find information about creating a Ranorex Snapshot here.


In this case, you can probably variabalize the GUID part of the @src property. You path would look like this:

Code: Select all

div[2]/div/div[4]//iframe[@src='/myForms/myContact.aspx?OBJID=-1&CompanyID=1234567890&guid=' + $varGuid]//input[#'Firstname]
Notice the "$varGuid". This is a variable that you would declare and fill with the GUID on the new page by using the GetValue action in the action table.

Re: Problem with guid in URL

Posted: Wed Mar 04, 2015 4:46 pm
by smp245
Thank you for your reply krstcs.

I am using Ranorex 5.3 with Windows 7. The application is a .Net application with numerous 3rd party controls.

Using the $varGuid you suggested helps me to capture the guid and works as long as the guid is already contained in the repository and obviously, is correct. Thank you!

My next hurdle is, everytime I run through the procedure of adding another contact a new guid is generated. It is this generated GUID I now need to capture and store without having to click on a web-page control (I can then refer to it using the variable $varGuid as you advised).

When I click on a column in a grid/report (repository item below) the guid is correctly tracked. However this guid is not visible in the pageurl, and it changes every time I open this grid/report.

I need to capture the guid from somewhere on the webpage before I complete the action below, then I should be able to replace the guid below with the variable $varGuid as mentioned above.

When I right-click on the webpage and view Properties I can see the guid in the url . Also, in the screenshot attached I can see the guid as part of the iFrameTag src but I just don't know how to retrieve this in the user code.

/dom[@domain='myServer01:82']//div[#'Tabs']//div[#'Tabs']//iframe[@src='myForms/CustJournal_devexpress.aspx?ACCOUNTID=2100026144&guid=2B59617E-DE5D-4F04-9D98-EDBD3D4F328B']//div[#'RAD_SPLITTER_PANE_CONTENT_RadPaneTopRight']/iframe[@id='RAD_SPLITTER_PANE_EXT_CONTENT_RadPaneTopRight']//tr[#'dg_dg_DXDataRow0']/td[6]

Many thanks in advance for your help.

Re: Problem with guid in URL

Posted: Thu Mar 05, 2015 5:36 pm
by krstcs
From what I understand, you should be able to capture the GUID you need an then store it in the variable and use it where you need it next. You may want to use a different variable like "varGUID_NEW".

Re: Problem with guid in URL

Posted: Mon Mar 09, 2015 12:16 pm
by smp245
Thank you, but how would I capture this? This is my problem, I cannot seem to find out how to do it successfully.

Thanks in advance

Re: Problem with guid in URL

Posted: Mon Mar 09, 2015 12:51 pm
by odklizec
Hi,

Have you tried "Get Value" action (check this user guide page)?

Simply Drag&Drop the page element containing the GUID to recording table and from the appeared context menu select "Get Value" action and "guid" attribute. Then in the recording table, select/create the variable in which you want to store the content of guid attribute. Hope this helps?

Re: Problem with guid in URL

Posted: Mon Mar 09, 2015 1:50 pm
by smp245
Sorry, I am obviously missing something her so please excuse my next question.

The guid is newly genereated each time I open the web page to run the test case, so I'm not sure that capturing the value from the repository is going to work, as the item in the repository has been previously populated with a previous value (I am currently having to change this manually each time it runs).

Can I replace the guid value in the repository with something that will be by the new guid each time the test case is run?

or, can I get the guid from the web page URL property - not in the repository
(to retrieve this information manually I right click on the page and see the full URL)

Many thanks

Re: Problem with guid in URL

Posted: Mon Mar 09, 2015 2:18 pm
by odklizec
Hi,

I think the main problem is that the xpaths of your repository elements contain guid strings? Because the guid strings are not persistent, you need to remove them from repository element xpaths and replace them with something more persistent. Apparently, Ranorex considered them unique enough or there is simply nothing else it could use for the unique element identification (like ID, "inner text",...). You may better to change the xpath weights to give the guid strings lower priority. I would strongly recommend you to start with this blog:
http://www.ranorex.com/blog/automated-t ... ynamic-ids

BTW, can you see the guid attribute in the DOM list of attributes (click "edit" button to see the available attributes)? If the guid is there, then use GetValue action with DOM element. otherwise, use another element containing the guid attribute. Again, make sure there is no guid element used in xpath anywhere in your repository (including the DOM element).