Class library usage, coding and language questions.
-
maamer
- Posts: 23
- Joined: Fri Nov 30, 2018 6:03 pm
Post
by maamer » Mon Feb 04, 2019 11:01 pm
Hello All,
I am Trying to read an HTML table. the columns in this table can be interchanged.
aVwdI-1.png
i am interested only in the Report ID column. My test case is click on view button (under Action column) of each report under Report ID. so iam trying to write a sample code for this.
Code: Select all
var repo = BottomLineIIRepository.Instance;
var tdTag601147168EDI = repo.DigitalBanking.LegacyReports.tablerows;
var aTagRxHyhbnvmfnk5oermy = repo.DigitalBanking.LegacyReports.ATagRxHyhbnvmfnk5oermy;
IList<Ranorex.TrTag> tablerow = repo.DigitalBanking.LegacyReports.tablerowsInfo.CreateAdapters<Ranorex.TrTag>();
IList<Ranorex.ATag> header = repo.DigitalBanking.LegacyReports.ATagRxHyhbnvmfnk5oermyInfo.CreateAdapters<Ranorex.ATag>();
var headings = new List<string>(); //saving the header of the table into a list.
foreach (Ranorex.ATag aitem in header){
string headername = aitem.Element.GetAttributeValueText("innertext").ToString();
headings.Add(headername);
}
int temp = headings.IndexOf("Report ID");//since the columns can be interchanged, getting the index value of Report ID column
int i = temp+1; // adding +1 because the first column Action=is spantag
Report.Info(i.ToString());
foreach (Ranorex.TrTag item in tablerow){
string reportname = item.Element.FindSingle("/td[@childindex='"+i+"']").GetAttributeValueText("innertext").ToString();//getting error here. calling the "i" into the child index
Report.Info(reportname);
}
i am sure that the "i" is same as child index in the spy.
2019-02-04 17_00_30-BottomLineII - Ranorex Studio (Administrator).png
please help.
Thank you.
You do not have the required permissions to view the files attached to this post.
-
odklizec
- Ranorex Guru
- Posts: 7470
- Joined: Mon Aug 13, 2012 9:54 am
- Location: Zilina, Slovakia
Post
by odklizec » Tue Feb 05, 2019 8:46 am
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
-
maamer
- Posts: 23
- Joined: Fri Nov 30, 2018 6:03 pm
Post
by maamer » Tue Feb 05, 2019 4:17 pm
Hello @odkizec ,
Thank you for the quick reply. the code is working now but it doesnot return the expected innertext of the td tag. i get 28 which is not even there in any of the element properties
2019-02-04 17_00_30-BottomLineII - Ranorex Studio (Administrator).png
is there a problem in the HTML parsing in ranorex?. i used chrome so i am ignoring the add on warning.
You do not have the required permissions to view the files attached to this post.
-
ahoisl
- Certified Professional
- Posts: 192
- Joined: Fri Sep 07, 2007 8:16 am
Post
by ahoisl » Tue Feb 05, 2019 10:45 pm
I guess the problem is that you need to specify a relative path. Paths with a leading "/" are always interpreted as absolute paths by Ranorex, so they will search from the root element.
Precede the path with a "." or omit the leading "/" altogether:
string reportname = item.Element.FindSingle("td[@childindex='"+i+"']")...
Regards,
Alex
Ranorex Team
-
odklizec
- Ranorex Guru
- Posts: 7470
- Joined: Mon Aug 13, 2012 9:54 am
- Location: Zilina, Slovakia
Post
by odklizec » Wed Feb 06, 2019 9:10 am
Heh, I'm always forgetting about this "./" trick in code
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