How to get the inner text by passing inner html line dynamically in the automation
I have interrogated a webpage which has 3 fields (all are readonly fields) in it and their InnerHtml were as below,
Field 1 - <label class="field-caption dataLabelForRead" for="T01">AAAA</label><div class="field-item dataValueRead"><span>XXXX</span></div>
Field 2 - <label class="field-caption dataLabelForRead" for="T02">BBBB</label><div class="field-item dataValueRead"><span>YYYY</span></div>
Field 3 - <label class="field-caption dataLabelForRead" for="T03">CCCC</label><div class="field-item dataValueRead"><span>ZZZZ</span></div>
Its not that all the time these 3 fields would be displayed in the page. Sometimes only 2 field would be displayed. So in such case, as i have the webpage interrogated, need to do the following,
1. Check whether the fields are available in the screen
2. If available get the respective output value (i.e, XXXX, YYYY and ZZZZ)
Note: In above Html lines, T01, T02, T03, AAAA, BBBB and CCCC are the names i have it in excel, so i can get the values from my excel sheet. where XXXX, YYYY and ZZZZ are the output i required.
For eg: I have given 3 fields here. In my application there are 30+ fields which needs to worked on. So it would be so helpful if there in one automation line which passes the parameters (T01, TC02, TC03, AAAA, BBBB, CCCC) dynamically.
Since there are only three fields, I am not sure why you cannot simply check to see if a given field is created and if so, pull its value into the appropriate place in your Excel sheet. That would be the easiest way to get a value out if the field exists.
If you have a possibility of N number of fields (where N can be any number), then you might want to interrogate one field and make its match rules such that it matches all N fields at once. You could then enable UseKeys and in your automation, you could use the GetClones method passed into a ListLoop to iterate all of the labels that are matched. You could check the inner HTML to get the "for" attribute and place it appropriately in your spreadsheet based on that.
Keep up to date on this post and subscribe to comments
- I have a requirement to show few lines of text [also has hyperlink inside the text], which is help text with "?" shown in the label of dynamic layout
- Passing parameters\variable to automation from command line
- Labels' text is wrapping to 2nd line using "Stacked with labels left" dynamic layout
- Is it possible to dynamically refer and set the value for web-controls without interrogation using its html attribute in automation.os