How to set a test case parameter value using user code

Ask general questions here.
itschinovic
Posts: 5
Joined: Wed Oct 11, 2017 10:37 am

How to set a test case parameter value using user code

Post by itschinovic » Tue Jan 23, 2018 12:32 pm

[img]Untitled.png[/img]
Attachments
Untitled.png
Untitled.png (23.03 KiB) Viewed 588 times

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

Re: How to set a test case parameter value using user code

Post by odklizec » Tue Jan 23, 2018 12:41 pm

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

itschinovic
Posts: 5
Joined: Wed Oct 11, 2017 10:37 am

Re: How to set a test case parameter value using user code

Post by itschinovic » Tue Jan 23, 2018 3:16 pm

Hi @odklizec I've tried to use the code

Code: Select all

aiFrameCtr = aiFrameCtr + 1; //Counter
        	string iFrameXpathTemporary = "PegaGadget{0}Ifr"; //Template
        	string iFrameXpathTemporary2 = string.Format(iFrameXpathTemporary , aiFrameCtr); //combining iFrameCtr and TemporaryXpath
        	string ConvertiFrameCtr = aiFrameCtr.ToString();
        	aiFrameXpath = iFrameXpathTemporary2; //Final xPath
        	TestSuite.CurrentTestContainer.Parameters["iFrameXpath"] = aiFrameXpath;
        	TestSuite.CurrentTestContainer.Parameters["iFrameCtr"] = ConvertiFrameCtr;
        	Report.Log(ReportLevel.Info, TestSuite.CurrentTestContainer.Parameters["iFrameXpath"]);
        	Report.Log(ReportLevel.Info, aiFrameXpath);
        	Report.Log(ReportLevel.Info, TestSuite.CurrentTestContainer.Parameters["iFrameCtr"]);
so the code update just for that recording but when it goes to the next step it goes back again so here are some pics for more details
Untitled.png
Initial State
Untitled.png (23.03 KiB) Viewed 573 times
step2.PNG
Here are the steps in my test case
step2.PNG (12.08 KiB) Viewed 573 times
step3.PNG
Here is the result after the run of usercode as u can see it updates what is in the previous parameter passed on to it
step3.PNG (10.94 KiB) Viewed 573 times
and this is the result of the next step as you can see "in bold case" the parameter that it used is still the old one and not the one updated by the user code

WaitForAttributeEqual failed. Element for item 'NSSRepository.NSS.ScreeningEvents.NationalScreeningSystem.Title.ScreeningEvents' does not exist (Failed to find item 'NSSRepository.NSS.ScreeningEvents.NationalScreeningSystem.Title.ScreeningEvents'. No element found for path '/dom[@domain='portaltest.extra.nehr.sg']//iframe[#'PegaGadget0Ifr']//div[#'HARNESS_CONTENT']/table//div[@id='RULE_KEY']//?/?/div[@innertext='Screening Events']' within 1m.).
Show/Hide Stacktrace

asdf
Posts: 174
Joined: Mon Mar 21, 2016 3:16 pm

Re: How to set a test case parameter value using user code

Post by asdf » Fri Jan 26, 2018 12:56 pm

If you change the value of a TestCase parameter, the value will be changed in the next TestCase.
2018-01-26 12_54_49-ParameterTest - Ranorex Studio.png
2018-01-26 12_54_49-ParameterTest - Ranorex Studio.png (6.5 KiB) Viewed 550 times
Hope that helps.