Changing Object Types
Posted: Wed Jun 30, 2010 9:09 am
Hi Team,
How do we change object type from one to another. For example, I would like to change an String to a RXPath type. Actually, I am getting the below error:
=======
Unexpected exception occured: System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Ranorex.Core.RxPath'.
=======
Dim cntryContainer As Ranorex.Container = repo.ContainerSelectbox.countryListContainer
Dim strCountryName As String = "AUSTRALIA"
Dim cntryXPath
cntryXPath = "/listitem[@accessiblename='"& strCountryName &"']"
Dim lstItem As ListItem = cntryContainer.FindSingle(Of ListItem)(cntryXPath)
lstItem.Click()
I tried converting String cntryXPath to RxPath like below, but didnt work.
Dim newrxPath as Ranorex.Core.RxPath = ConvertFromString(cntryXPath)
I got the below error which suggests that this is not the correct way of using it:
"Reference to a non-shared member requires an object reference. (BC30469) -"
Can anyone please help.
Thanks and Regards,
Aakash
How do we change object type from one to another. For example, I would like to change an String to a RXPath type. Actually, I am getting the below error:
=======
Unexpected exception occured: System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Ranorex.Core.RxPath'.
=======
Dim cntryContainer As Ranorex.Container = repo.ContainerSelectbox.countryListContainer
Dim strCountryName As String = "AUSTRALIA"
Dim cntryXPath
cntryXPath = "/listitem[@accessiblename='"& strCountryName &"']"
Dim lstItem As ListItem = cntryContainer.FindSingle(Of ListItem)(cntryXPath)
lstItem.Click()
I tried converting String cntryXPath to RxPath like below, but didnt work.
Dim newrxPath as Ranorex.Core.RxPath = ConvertFromString(cntryXPath)
I got the below error which suggests that this is not the correct way of using it:
"Reference to a non-shared member requires an object reference. (BC30469) -"
Can anyone please help.
Thanks and Regards,
Aakash