Page 1 of 1

RepoItemInfo runtime creation

Posted: Tue Mar 12, 2019 4:17 pm
by rsudhak

Code: Select all

public static void selectTextItemFromSizeAndRating(string itemToSelect){
			List combo = ProDesign.CableSettingsDialog.ComboBox_SizeRating;
			RxPath comboPath = ProDesign.CableSettingsDialog.ComboBox_SizeRatingInfo.AbsolutePath;
			Ranorex.Core.Repository.RepoItemInfo comboInfo = ProDesign.CableSettingsDialog.ComboBox_SizeRatingInfo;
			IEnumerable<Ranorex.Core.Repository.RepoItemInfo> childrenInfo = ProDesign.CableSettingsDialog.ComboBox_SizeRatingInfo.Children;
			
	
			
			combo.EnsureVisible();
			
			combo.Click();
			var items = combo.Items;
			var totalItems = items.Count;
			//List<Ranorex.Core.Repository.RepoItemInfo> items1 = (List)childrenInfo;
			for(int i = 0; i< items.Count;i++) {
				
				 																																												
				Ranorex.Core.Repository.RepoItemInfo itemInfo = new Ranorex.Core.Repository.RepoItemInfo(comboInfo.ParentFolder,"itemInfo",new RxPath(comboPath+"//listitem["+i+"]/"),1000,false,"99999999-9999-9999-9999-999999999999");
				
				string abc = itemInfo.FindAdapter<Text>().GetAttributeValue<Text>("name").ToString(); // FAILS IN THIS LINE//
				System.IO.File.WriteAllText(@"C:\Rajee\sizerating.txt",abc);
				ListItem item = items[i];

				string itemTextSize = ((ListItem)item).Children[0].Element.GetAttributeValue("name").ToString();
				string itemTextRating = ((ListItem)item).Children[1].Element.GetAttributeValue("name").ToString();
				//itemText = itemText.Replace("/", String.Empty);
				string itemText = new StringBuilder(itemTextSize).Append("/").Append(itemTextRating).Replace(" ", "").ToString().ToUpper();;
				itemInfo=null;
				if(itemToSelect.Equals(itemText)) {
					combo.SelectedItemIndex = i;
					break;
				}
			}
eRROR :
Failed to find item 'DesignerSuiteAutomatedTestingRepository.ProDesign2016.Dialog_CableSettings.itemInfo'.
No element found for path '/form[@title='Cable Settings' or @title~'^Final\ Circuit\ ' or @title~'^Lighting\ Column\ ' and @processname='ProDesign']/form[@title='Cable Settings' or @title~'^Final\ Circuit\ ' or @title~'^Lighting\ Column\ ' and @processname='ProDesign']/container[@automationid='Main']//container[@automationid='ComponentSettingsView']/container/container/element[@automationid='PageContentControl']//container[@automationid='CableTypeViewElement']/container/container[6]/list[@automationid='RatingComboBox']//listitem[0]' within 31s.
Show/Hide Stacktrace
at Ranorex.Core.Repository.RepoItemInfo.FindInternal[T](Boolean findSingle, Boolean throwException, Duration effectiveTimeoutOverride)at Ranorex.Core.Repository.RepoItemInfo.<>c__DisplayClass75_0`1.<Find>b__0()at Ranorex.Core.Testing.Services.NoMaintenanceModeService.HandleElementNotFound[T](Func`1 action, RepoItemInfo entry)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 Ranorex.Core.Repository.RepoItemInfo.FindAdapter[T]()at ProdesignAutomatedTesting.ProDesign_Files.UI_Elements_Engine.CablesHelper.selectTextItemFromSizeAndRating(String itemToSelect) in c:\git\designsuiteautomatedtesting\ProdesignAutomatedTesting\ProdesignAutomatedTesting\ProDesign Files\UI Elements Engine\CablesHelper.cs:line 281at ProdesignAutomatedTesting.ProDesign_Files.UI_Elements_Engine.CablesHelper.SelectCable_SizeAndRating(String itemToSelect) in c:\git\designsuiteautomatedtesting\ProdesignAutomatedTesting\ProdesignAutomatedTesting\ProDesign Files\UI Elements Engine\CablesHelper.cs:line 103at ProdesignAutomatedTesting.ProDesign_Files.ProDesign_Dialog_Events.EditProperties.SelectCable_SizeAndRating(String sTextToSelect) in c:\git\designsuiteautomatedtesting\ProdesignAutomatedTesting\ProdesignAutomatedTesting\ProDesign Files\ProDesign Dialog Events\EditProperties.cs:line 470at ProdesignAutomatedTesting.ProDesign_Files.ProDesign_Test_Setup_Files.Draw_NewCableDataTest.Ranorex.Core.Testing.ITestModule.Run() in c:\git\designsuiteautomatedtesting\ProdesignAutomatedTesting\ProdesignAutomatedTesting\ProDesign Files\ProDesign Test Setup Files\Draw_NewCableDataTest.cs:line 208at Ranorex.Core.Testing.TestModuleLeaf.RunInternal(DataContext parentDataContext, Int32 iteration, Int32 iterationCount, Boolean skipIteration)



Here I am trying to create an repoiteminfo for each element in the list, any idea as to how to go forward with this one?

Thanks,
rajee

Re: RepoItemInfo runtime creation

Posted: Tue Mar 12, 2019 4:22 pm
by N612
Hi rajee, perhaps this is what you are looking for: https://www.ranorex.com/help/latest/han ... oryelement

If not, please explain why this does not work for you and we can look into alternative methods :)

Re: RepoItemInfo runtime creation

Posted: Tue Mar 12, 2019 5:00 pm
by rsudhak
Thanks for the reply,

I still have issue:

Code: Select all

public static void selectTextItemFromSizeAndRating(List combo,string itemToSelect){
			Ranorex.Core.Repository.RepoItemInfo comboInfo = ProDesign.CableSettingsDialog.ComboBox_SizeRatingInfo;
			combo.EnsureVisible();
			itemToSelect = itemToSelect.Replace(" ","").ToUpper();
			combo.Click();
			IList<ListItem> listitems = comboInfo.CreateAdapters<ListItem>();
			
			foreach (ListItem item in listitems)
			{
				
				string itemTextSize = item.Children[0].GetAttributeValue<Text>("text").ToString();
				string itemTextRating = item.Children[1].GetAttributeValue<Text>("text").ToString();
				
				string itemText = new StringBuilder(itemTextSize).Append("/").Append(itemTextRating).Replace(" ", "").ToString().ToUpper();
				System.IO.File.WriteAllText(@"C:\Rajee\sizerating.txt",itemText);
				if(itemToSelect.Equals(itemText)) {
					combo.SelectedItemIndex = item.Index;
					break;
				}
			} 
path looks like this :

listitem1:
list/lititem[0][/Text[0]
list/lititem[0]/Text[1]

listitem2:
list/lititem[1][/Text[0]
list/lititem[1]/Text[1] ... and so on...

need to find the test innside each listitem , any idea how?

Re: RepoItemInfo runtime creation

Posted: Tue Mar 12, 2019 5:47 pm
by odklizec
Hi,

Could you please post a Ranorex snapshot (NOT screenshot) of the problematic list? Without, at very least, Ranorex snapshot, it’s very hard to suggest something reliable.

At next, as far as I know, there is no way to create a repoiteminfo element from code. It’s only possible to create an adapter from repoiteminfo, but not vice versa. But maybe there is another way to achieve what you want. Just post the snapshot and a more detailed description of what you are after. Thanks.

Re: RepoItemInfo runtime creation

Posted: Wed Mar 13, 2019 8:48 am
by rsudhak
Just wanted to know what are the possible solution, how do I create an adaptor for this one?

Re: RepoItemInfo runtime creation

Posted: Wed Mar 13, 2019 9:03 am
by odklizec
Hi,

Please post a Ranorex snapshot of the problematic list. Without snapshot, I can only redirect you to the sample code N612 already suggested...
https://www.ranorex.com/help/latest/han ... oryelement