Dynamic Number in Table is not getting captured

Ranorex Spy, Recorder, and Studio.
javier.calderon
Posts: 6
Joined: Tue Jul 07, 2015 8:27 pm

Dynamic Number in Table is not getting captured

Post by javier.calderon » Wed Jul 15, 2015 6:38 pm

Hello,

I am trying to get a VIN number from the table. The problem is the spy recognizes the object based on the innertext of that element. The problem is that once I process a payment that VIN is no longer available. When I try to run the test again Ranorex gets stuck because it cannot find the innertext. I need it to just grab any VIN and be able to make that a variable. I have attached screen shots.
Attachments
table.png
table.png (56.33 KiB) Viewed 1159 times
object spy.png
object spy.png (155.48 KiB) Viewed 1159 times

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

Re: Dynamic Number in Table is not getting captured

Post by odklizec » Thu Jul 16, 2015 9:59 pm

Hi,

I'm not sure what exactly you want to achieve? Get all VINs from the table and then what?

It should be possible to obtain all VINs (and store them in a list of strings) using a carefully constructed xpath, containing "VIN:" string? Unfortunately, it's hard to create such xpath without seeing the Ranorex snapshot of given table. If you cannot/don't want to upload the snapshot publicly, try to send it to [email protected].
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

javier.calderon
Posts: 6
Joined: Tue Jul 07, 2015 8:27 pm

Re: Dynamic Number in Table is not getting captured

Post by javier.calderon » Fri Jul 17, 2015 3:31 pm

I just need it to capture any VIN in that table and assign it to a variable. Ideally I just need to be able to look at the table and say go to Row1, Column 3 get that VIN(which changes all the time) and assign it to a variable. I just need a way to capture that dynamic field because once I process a VIN that entry disappears from the table.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Dynamic Number in Table is not getting captured

Post by krstcs » Fri Jul 17, 2015 4:26 pm

Try changing your RanoreXPath to use something besides the innertext attribute when identifying the element you need.

You can use the column number if you have to (but using indexes like that can cause things to be brittle in the long run, such as if the developers change the column order). You could use Regex to find the cell with both 'VIN' and 'STK' in the text. Then grab the innertext and parse out the actual vin in usercode.

/div[@innertext~'VIN' and @innertext~'STK']

Without seeing a snapshot of the structure it is hard to help though, as Pavel said. :D
Shortcuts usually aren't...

javier.calderon
Posts: 6
Joined: Tue Jul 07, 2015 8:27 pm

Re: Dynamic Number in Table is not getting captured

Post by javier.calderon » Fri Jul 17, 2015 5:05 pm

Here is the snapshot.
Attachments
vin.rxsnp
(801.86 KiB) Downloaded 68 times

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Dynamic Number in Table is not getting captured

Post by krstcs » Fri Jul 17, 2015 5:55 pm

/dom[@domain='test.nextgearcapital.com']//table[#'paymentsSearchTable']/tbody/tr[1]/td[@class='description-narrow']/div/p/span/span[@innerText='VIN']

That path will find the span with innertext='VIN' in the 1st row ('tr[1]') of the table.

You should probably look into using rooted folders for the table and each row. Then you would use the XPath that gets you the row you want for the row folder. Inside that you could have repo items for each of the columns or pieces of info inside the columns, depending on what you need to do.
Shortcuts usually aren't...

javier.calderon
Posts: 6
Joined: Tue Jul 07, 2015 8:27 pm

Re: Dynamic Number in Table is not getting captured

Post by javier.calderon » Fri Jul 17, 2015 6:18 pm

When I run it this just returns the value VIN and not the number sequence. Is there a way to just capture the actual numbers?

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

Re: Dynamic Number in Table is not getting captured

Post by odklizec » Mon Jul 20, 2015 7:33 am

Hi,

I would suggest to use xpath like this:

Code: Select all

/dom[@domain='test.nextgearcapital.com']//table[#'paymentsSearchTable']/tbody/tr/td[@class='description-narrow']/div/p/span/span[@innertext='VIN']/../../span[@innertext~'.*']
The regex in last span is a rough one. You should have to find/construct a correct regular expression for VIN numbers validation. But for now, the one from my example should do the trick ;)

The above path will return all spans containing VIN numbers.

What you need to do now is to process the list of obtained spans, to obtain the individual VIN numbers and do whatever you want with them. You can use something like this:
public void GetVINNumbers(Ranorex.Core.Repository.RepoItemInfo spanTagVIN)
        {
        	// Create a list of adapters using the "Info" object  
			IList<Ranorex.SpanTag> spanList =   
			    spanTagVIN.CreateAdapters<Ranorex.SpanTag>();  
			  
			// Get VIN number from each found span and print it in Report      
			foreach (Ranorex.SpanTag spanVIN in spanList )  
			{  
			    string vinValue = spanVIN.InnerText;  
			    Report.Info("Available VIN number: " + vinValue);
			}   
        }
Hope this helps?
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

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Dynamic Number in Table is not getting captured

Post by krstcs » Mon Jul 20, 2015 2:34 pm

Yeah, sorry, I should have added that you would need to get the actual value of the VIN by making an XPath based off what I posted.

Thanks Pavel for adding that. :D

I would suggest learning as much about XPath and how Ranorex uses it as you possibly can, as well as learning RegEx. There are many problems in Ranorex automation that can be solved by the proper application of those technologies. In my opinion, these are the most important things to learn with Ranorex.
Shortcuts usually aren't...

javier.calderon
Posts: 6
Joined: Tue Jul 07, 2015 8:27 pm

Re: Dynamic Number in Table is not getting captured

Post by javier.calderon » Thu Jul 30, 2015 2:38 pm

Thanks. I was able to get the value from using span[@innertext~'.*'] at the end. It grabs whatever the first value is.