Hi..
I am using following code get value from UI " objName.Element.GetAttributeValue("Value").ToString=strTextValue " but it is giving run time error
"Object reference not set to an instance of an object" when the object value is blank in UI. But my requirement is to fetch even blank values..
Instead if i use " objName.Element.GetAttributeValue("Value")=strTextValue " it works but gives a warning "Implicit Conversion from Object to String"
Plz help to resolve this issue..
Object reference not set to an instance of an object
Re: Object reference not set to an instance of an object
Hi,
It seems you forgot to add parentheses at the end of ToString method, so the code should be like this...
It seems you forgot to add parentheses at the end of ToString method, so the code should be like this...
objName.Element.GetAttributeValue("Value").ToString()
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: Object reference not set to an instance of an object
Thanks for your reply.. I tried by adding .ToString() but still getting that error..
I tried in this way Report.Log(ReportLevel.Info,repo.brsMediaView.objLabel.Element.GetAttributeValue("Value").ToString())

I tried in this way Report.Log(ReportLevel.Info,repo.brsMediaView.objLabel.Element.GetAttributeValue("Value").ToString())
Re: Object reference not set to an instance of an object
Are you sure the repo.brsMediaView.objLabel has "Value" attribute? Could you please upload the Ranorex snapshot of the element in question (repo.brsMediaView.objLabel)?
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: Object reference not set to an instance of an object
Try changing "GetAttributeValue" to "GetAttributeValueText" and remove the ".ToString()" part.
Code: Select all
Report.Log(ReportLevel.Info,repo.brsMediaView.objLabel.Element.GetAttributeValueText("Value"));
Shortcuts usually aren't...
Re: Object reference not set to an instance of an object
@odklizec.. yes object has attribute "Value".. Solution provided by krstcs is working fine..
Thanks to both of you
my problem is solved..
Thanks to both of you
