iterate through h2tag elements and get innertext!

Class library usage, coding and language questions.
manish
Certified Professional
Certified Professional
Posts: 53
Joined: Fri Aug 10, 2018 12:46 pm

Re: iterate through h2tag elements and get innertext!

Post by manish » Wed Feb 24, 2021 10:31 am

Hi,

Could you try using the Find to get all H2Tags from your repo element.

Something like this

Code: Select all

			var repo = BottomLineIIRepository.Instance;
			var acclist = repo.DigitalBanking.Accounts.acclist;
			Report.Log(ReportLevel.Info,"starting test");

			IList<Ranorex.H2Tag> accnamelist = repo.DigitalBanking.Accounts.acclistInfo.Find<H2Tag>("//h2tag");
			List<Ranorex.H2Tag> names = new List<H2Tag> {};
			foreach (var tagh2 in accnamelist){
				names.Add(tagh2.Element.GetAttributeValueText("innertext").ToString());
				Report.Info("account name is: "+names);
			}

This will give all the J2tags present below acclist . If you wish to find only the immediate children then use FindChildren method.

Thanks
Manish