RepoItemInfo runtime creation

Ask general questions here.
rsudhak
Posts: 78
Joined: Fri Jan 04, 2019 1:38 pm

RepoItemInfo runtime creation

Post by rsudhak » Tue Mar 12, 2019 4:17 pm

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

User avatar
N612
Posts: 108
Joined: Mon Jul 11, 2016 4:01 pm

Re: RepoItemInfo runtime creation

Post by N612 » Tue Mar 12, 2019 4:22 pm

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 :)

rsudhak
Posts: 78
Joined: Fri Jan 04, 2019 1:38 pm

Re: RepoItemInfo runtime creation

Post by rsudhak » Tue Mar 12, 2019 5:00 pm

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?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5353
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: RepoItemInfo runtime creation

Post by odklizec » Tue Mar 12, 2019 5:47 pm

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

rsudhak
Posts: 78
Joined: Fri Jan 04, 2019 1:38 pm

Re: RepoItemInfo runtime creation

Post by rsudhak » Wed Mar 13, 2019 8:48 am

Just wanted to know what are the possible solution, how do I create an adaptor for this one?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5353
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: RepoItemInfo runtime creation

Post by odklizec » Wed Mar 13, 2019 9:03 am

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
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration