Page 1 of 1

SharePoint Form Element ID

Posted: Tue Nov 21, 2017 7:11 pm
by sfrychel
[attachment=0]PayoffLoanNo.zip[/attachment]
I can't seem to get Ranorex to locate the elements after I do a recording.

I go through a SharePoint Form clicking and recording the whole way. But when I try to Run the test Ranorex cannot locate the element/fields.
In other environments I've easily updated the Path but with this I can't follow what the path is even saying.

I am attaching a snapshot. Wow for just one field my snapshot was too large I had to use .zip! Hmm I may have done something wrong.

Re: SharePoint Form Element ID

Posted: Tue Nov 21, 2017 9:04 pm
by odklizec
Hi,

Please post a sample xpath as recorded by Ranorex. And also your modified xpath. Plus post the exact error message you are getting.

You see, without more details about your problem, it's hard to tell what's wrong.

All I can say right now is that Ranorex recorder is a nice and very helpful tool, but you should not expect that all recorded xpath are optimal. You should always check each xpath and eventually perform some optimalizations to make them recognizable in long run.

Re: SharePoint Form Element ID

Posted: Tue Nov 21, 2017 9:28 pm
by sfrychel
I thought that the snapshot contained the xPath but here is a copy of the Xpath for you:

/dom[@domain='republicinfo']//select[#'ctl00_ctl39_g_69098cb4_ae14_4c15_9aa4_c247f569fd61_ctl00_ListForm2_formFiller_FormView_ctl22_ctl32_ctl08_211d1962_0790_415a_950d_b4d9f6a5106a']


Here is the error from the report.
Failed to find item 'TestSharepointRepository.PayoffQuoteRequestStageNewItem.Ctl00Ctl39G69098cb4Ae144c159aa4C2'.
No element found for path '/dom[@domain='republicinfo']//select[#'ctl00_ctl39_g_69098cb4_ae14_4c15_9aa4_c247f569fd61_ctl00_ListForm2_formFiller_FormView_ctl22_ctl32_ctl08_211d1962_0790_415a_950d_b4d9f6a5106a']' within 1m.
Show/Hide Stacktrace
at Ranorex.Core.Repository.RepoItemInfo.Find[T](Boolean findSingle, Boolean throwException, Duration effectiveTimeoutOverride) at Ranorex.Core.Repository.RepoItemInfo.CreateAdapter[T](Boolean throwException, Duration waitTimeout) at Ranorex.Core.Repository.RepoItemInfo.CreateAdapter[T](Boolean throwException) at TestSharepoint.TestSharepointRepositoryFolders.PayoffQuoteRequestStageNewItemAppFolder.get_Ctl00Ctl39G69098cb4Ae144c159aa4C2() in C:\Users\SFrychel\Documents\Ranorex\RanorexStudio Projects\TestSharepoint\TestSharepoint\TestSharepointRepository.cs:line 157 at TestSharepoint.Recording1.Ranorex.Core.Testing.ITestModule.Run() in C:\Users\SFrychel\Documents\Ranorex\RanorexStudio Projects\TestSharepoint\TestSharepoint\Recording1.cs:line 83 at Ranorex.Core.Testing.TestModuleLeaf.RunInternal(DataContext parentDataContext, Int32 iteration, Boolean skipIteration

Re: SharePoint Form Element ID

Posted: Wed Nov 22, 2017 8:26 am
by odklizec
Hi,

Exactly what I thought. The ID recorded by Ranroex is dynamic one. Which means, it's useless for test automation, because it could change with each AUT build or even start! You need to use different attribute for control identification. A very useful article about automating apps with dynamic IDs can be found here:
https://www.ranorex.com/blog/automated- ... namic-ids/

After looking at snapshot you provided, I think you will have to use a combination of Title and Id processed with regex. Eventually, you can use an xpath with relationship operators, to find one element (e.g. input) based of the name/title/innertext of another related element (e.g. label). Here is an example of simplified xpath, which should find the input using its label:
/dom[@domain='republicinfo']//div[@id='formFillerDiv']//span[@innertext='Loan Number:']/ancestor::div[@title~'Enter the Loan Number']/following-sibling::div//input[@visible='True'][1]
Unfortunately for you, recorder will most probably not help you much and you will have manually process each recorded xpath.

Re: SharePoint Form Element ID

Posted: Tue Nov 28, 2017 2:19 pm
by sfrychel
Thank you for your assistance.