Hi All,
I am running into an issue trying to getvalue of a specific element. The element has the chance to either be innerText or TagValue depending upon how the number is stored. I would like to create a method to first check what tag the number is stored in and then get that value based on that tag. I thought this could be done using an if statement to check if either tagvalue or innertext is null or if either exists, but I am striking out. Any thoughts?
Thanks,
Keenan
GetValue when Element Tag could change
Re: GetValue when Element Tag could change
Hi Keenon,
You can try for example this code:
Hope this helps?
You can try for example this code:
public void CheckRepoItemValue(Ranorex.Adapter repoItem) { Ranorex.WebElement repoItemWebElement = repoItem.Element; if (repoItemWebElement.TagValue!=null & repoItemWebElement.InnerText!=null) { // both TagValue and InnerText is not null // do whatever you want } else if (repoItemWebElement.InnerText!=null) { // InnerText is not null // do whatever you want } else if (repoItemWebElement.TagValue!=null) { // TagValue is not null // do whatever you want } else { // both InnerText and TagValue is null // do whatever you want } }You can simply add a new UserCode action (with the above code) to recording of your choice, then assign a repository item to the UserCode parameter repoItem.
Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: GetValue when Element Tag could change
Thank you so much Pavel. This is exactly what I needed. I also found that before reaching the element during navigation, there is a clear indication that the tag will be innertext or tagvalue so I figure there are also other ways to write this as well, but I will be using what you mentioned. I appreciate you spending the time to help.
Thanks,
Keenan
Thanks,
Keenan
Re: GetValue when Element Tag could change
Hi Keenan,
You are welcome. I'm glad I could help
You are welcome. I'm glad I could help

Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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