Unable to set value using SetPropertyValue()! Help

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
aravin
Posts: 47
Joined: Mon Mar 09, 2015 7:43 am

Unable to set value using SetPropertyValue()! Help

Post by aravin » Tue May 12, 2015 1:34 pm

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!!!

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

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

Post by krstcs » Wed May 13, 2015 1:46 pm

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?
Shortcuts usually aren't...

aravin
Posts: 47
Joined: Mon Mar 09, 2015 7:43 am

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

Post by aravin » Thu May 14, 2015 6:38 am

Ranorex version? 5.3.2
Windows version? Windows 7
Technology of system under test? Objective C

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

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

Post by odklizec » Thu May 14, 2015 7:20 am

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 ;)
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

aravin
Posts: 47
Joined: Mon Mar 09, 2015 7:43 am

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

Post by aravin » Thu May 14, 2015 8:14 am

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 :)

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

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

Post by odklizec » Thu May 14, 2015 9:19 am

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 ;)
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

aravin
Posts: 47
Joined: Mon Mar 09, 2015 7:43 am

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

Post by aravin » Thu May 14, 2015 10:11 am

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. 

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

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

Post by odklizec » Thu May 14, 2015 10:28 am

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")
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

aravin
Posts: 47
Joined: Mon Mar 09, 2015 7:43 am

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

Post by aravin » Thu May 14, 2015 12:14 pm

The Explorer,

Yeah.. Fine.

Thanks for your response.!!