Validate InnerText pulled from a Data Source

Ranorex Studio, Spy, Recorder, and Driver.
chrisKibble
Posts: 2
Joined: Tue Feb 16, 2016 3:22 pm

Validate InnerText pulled from a Data Source

Post by chrisKibble » Tue Feb 16, 2016 3:38 pm

Hi Forum,

I am trying to validate text inside a Span, InnerText using the recording module however the text is being populated from an Excel Connector using the formula "NOW()" so that the title will be unique.

I have created 1 recording module (module 1), with an Excel Data Source that is pointing at an excel .xslb document with 1 active cell. The cell is "NOW()" formula so that the data used is always unique to the test run. So for example, I've filled out a form title and saved the form.

I have then created another recording module (module 2) referencing the same Excel Data Source that I want to validate the data entry from in Module 1. So for example, I now want to validate the form title is correct.

1) When I run the test will the Excel Data Source be checked when recording module 1 is run and then checked again when recording module 2 is run so the unique value will be different due to seconds passing?

2) Is it possible to create a "store" so to speak, that will take the first entry from the Excel Data Source when module 1 is run, and I can validate against that in module 2 rather than calling the Excel Data source again?

Any help is massively appreciated. Please bare in mind that I am brand new to Ranorex.

Regards,

Chris

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

Re: Validate InnerText pulled from a Data Source

Post by odklizec » Wed Feb 17, 2016 2:18 pm

Hi Chris,

Well, I think the easiest solution is to create a Global Parameter in your Test Suite (e.g. called 'gp_NowDateTime').

Then add below code to code module called at start of your TS (best to 'Setup' section)...

Code: Select all

var curTC = TestSuite.Current.GetTestCase("NameOfTC"); //load data connector containing Now() function
string nowDateTimeStr = curTC.DataContext.CurrentRow.Values[curTC.DataContext.Source.Columns["nowColumName"].Index]; //get nowDateTimeStr from loaded Excel data connector (replace 'nowColumName' with actual column name)							
TestSuite.Current.Parameters["gp_NowDateTime"] = nowDateTimeStr; //store the string obtained from Excel in 'gp_NowDateTime' global parameter.
Then simply bind the global parameter with modules in which you want to evaluate the Now value obtained from Excel. Hope this helps?

Anyway, if there is just Now() function used in mentioned Excel file, I would suggest to replace data connector with custom C# code generating actual date-time, e.g.

Code: Select all

System.DateTime dateOutput = System.DateTime.Today;
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

chrisKibble
Posts: 2
Joined: Tue Feb 16, 2016 3:22 pm

Re: Validate InnerText pulled from a Data Source

Post by chrisKibble » Thu Feb 18, 2016 12:01 pm

Thank you for this reply. I will attempt this myself however I was hoping this could of been done without a code module.

I will try your solution anyway and thank you for the help!

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

Re: Validate InnerText pulled from a Data Source

Post by odklizec » Thu Feb 18, 2016 12:44 pm

Hi,

I'm afraid, there is no way to achieve what you want without using some code. At least I don't see any way ;)
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