Page 1 of 1

Unable to set value using SetPropertyValue()! Help

Posted: Tue May 12, 2015 1:34 pm
by aravin
Hi, I need to dymanically set the value to the form in my mobile app (iOS).
However I am getting run time error, "Object reference not set to an instance of an object. "

I code included the code below.

Code: Select all

private void onlyTest()
		{
			try
			{
				Ranorex.Control dummy1=repo_ios.catalog.dummyInfo.CreateAdapter<Ranorex.Control>(false);
				dummy1.SetPropertyValue("value","0.89");
				string op=dummy1.GetPropertyValue("value").ToString();
				Report.Info(op);
			}
			catch(Exception ex)
			{
				Report.Info(ex.Message);
				Report.Info(ex.StackTrace);
			}
		}
Error Message:

Code: Select all

00:43.264 Info User  Object reference not set to an instance of an object.  
Give me a solution for this!!!

Re: Unable to set value using SetPropertyValue()! Help

Posted: Wed May 13, 2015 1:46 pm
by krstcs
Without more information it will be almost impossible to help you.

Ranorex version?
Windows version?
Technology of system under test? (You said iOS, but not what language, etc.)

You show some code, but didn't include any of the calling module's code. Where are variables set? What are they set to?

Re: Unable to set value using SetPropertyValue()! Help

Posted: Thu May 14, 2015 6:38 am
by aravin
Ranorex version? 5.3.2
Windows version? Windows 7
Technology of system under test? Objective C

Re: Unable to set value using SetPropertyValue()! Help

Posted: Thu May 14, 2015 7:20 am
by odklizec
Hi,

I can be wrong, but I think the SetPropertyValue is not available for iOS elements? From the API documentation it looks like it's only available only for .NET WinForms, JavaElement and FlexElements? I think you need to use SetAttributeValue instead. Hope Ranorex folks will correct me if I'm wrong ;)

Re: Unable to set value using SetPropertyValue()! Help

Posted: Thu May 14, 2015 8:14 am
by aravin
Hi Explorer,

It works on iOS app too.

The following code worked for me,

Code: Select all

Report.Log(ReportLevel.Info, "Set Value", "Setting attribute fieldValue to '0.95' on item 'apprepo'.", repo.appname.SelfInfo, new RecordItemIndex(0));
			repo.appname.Self.Element.SetAttributeValue("fieldValue", "0.95"); 
Thank you :)

Re: Unable to set value using SetPropertyValue()! Help

Posted: Thu May 14, 2015 9:19 am
by odklizec
Hi,

Thanks for heads up! Yes, the SetAttributeValue is supposed to work on iOS. I'm still not sure about SetPropertyValue you tried to use before ;)

Re: Unable to set value using SetPropertyValue()! Help

Posted: Thu May 14, 2015 10:11 am
by aravin
Hi Explorer,

Then why do I faced that error previously.

Code: Select all

00:43.264 Info User  Object reference not set to an instance of an object. 

Re: Unable to set value using SetPropertyValue()! Help

Posted: Thu May 14, 2015 10:28 am
by odklizec
Hi,

Well, I think it was because previously, you tried to use SetPropertyValue...

Code: Select all

dummy1.SetPropertyValue("value","0.89")
But in your working code, there is used SetAttributeValue:

Code: Select all

repo.appname.Self.Element.SetAttributeValue("fieldValue", "0.95")

Re: Unable to set value using SetPropertyValue()! Help

Posted: Thu May 14, 2015 12:14 pm
by aravin
The Explorer,

Yeah.. Fine.

Thanks for your response.!!