Hi,
i am having a string which has some path like
Dim chb_str as string ="/dom[@domain='............................................./div/div"
Dim name as string="Asia"
Dim rxp As New Rxpath(path_div)
Dim main_path as DivTag = rxp
Dim child_atag As Ranorex.ATag = main_path.FindSingle(Of Ranorex.ATag)("./div/div/table/tbody/tr/td/a[@InnerText='"+name.ToString+"']")
now i am getting an error as below
System.NullReferenceException: Object reference not set to an instance of an object.
at Ranorex.Core.Path.LocationStep..ctor(ITree stepTree, RxPath owner)
at Ranorex.Core.RxPath.TryInit(String path)
--- End of inner exception stack trace ---
at Ranorex.Core.RxPath..ctor(String path)
How to convert string to divtag
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to convert string to divtag
Which of the RxPaths in your code causes the problem? The first one (chb_str) or the one passed to the FindSingle method?
Which Ranorex version do you use?
Please, post the complete RxPath that causes the exception and the complete exception text (seems like the exception message you posted is taken from the inner exception only)!
Regards,
Alex
Ranorex Team
Which Ranorex version do you use?
Please, post the complete RxPath that causes the exception and the complete exception text (seems like the exception message you posted is taken from the inner exception only)!
Regards,
Alex
Ranorex Team
Re: How to convert string to divtag
Dim chb_str as string ="/dom[@domain='............................................./div/div"
Dim name as string="Asia"
Dim item As Ranorex.ATag = Nothing
Dim child_name As String = name.ToString
Dim rxp As RxPath = path_div
Dim child_atag As Ranorex.ATag = rxp.FindSingle(Of Ranorex.ATag)("./div/div/table/tbody/tr/td/a[@InnerText='"+name.ToString+"']")
Dim rxpath as String = child_atag.GetPath().ToString
Dim a_found As Boolean =main_divtag.TryFindSingle(rxpath,item)
If a_found Then
------
else
------
getting an error that Findsingle is not a member of Ranorex.core.Rxpath
Dim name as string="Asia"
Dim item As Ranorex.ATag = Nothing
Dim child_name As String = name.ToString
Dim rxp As RxPath = path_div
Dim child_atag As Ranorex.ATag = rxp.FindSingle(Of Ranorex.ATag)("./div/div/table/tbody/tr/td/a[@InnerText='"+name.ToString+"']")
Dim rxpath as String = child_atag.GetPath().ToString
Dim a_found As Boolean =main_divtag.TryFindSingle(rxpath,item)
If a_found Then
------
else
------
getting an error that Findsingle is not a member of Ranorex.core.Rxpath
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to convert string to divtag
...because you cannot invoke FindSingle on a path, only on an element. You have to search for "rxp" first, e.g. by assigning it to an element variable:sham526 wrote:getting an error that Findsingle is not a member of Ranorex.core.Rxpath
Dim rxp As String = "your RanoreXPath" Dim divTag As DivTag = rxp Dim child_atag As Ranorex.ATag = rxp.FindSingle(...)I suggest reading the Ranorex Tutorial and a few chapters in the Ranorex User Guide, especially this one:
http://www.ranorex.com/support/user-gui ... apter.html
Regards,
Alex
Ranorex Team
Re: How to convert string to divtag
I tried that one also.
Dim chb_str as string ="/dom[@domain='............................................./div/div"
Dim name as string="Asia"
Dim rxp As New Rxpath(path_div)
Dim main_path as DivTag = rxp
Dim child_atag As Ranorex.ATag = main_path.FindSingle(Of Ranorex.ATag)("./div/div/table/tbody/tr/td/a[@InnerText='"+name.ToString+"']")
now i am getting an error as below for the line =======> Dim main_path as DivTag = rxp
System.NullReferenceException: Object reference not set to an instance of an object.
at Ranorex.Core.Path.LocationStep..ctor(ITree stepTree, RxPath owner)
at Ranorex.Core.RxPath.TryInit(String path)
--- End of inner exception stack trace ---
at Ranorex.Core.RxPath..ctor(String path)
Dim chb_str as string ="/dom[@domain='............................................./div/div"
Dim name as string="Asia"
Dim rxp As New Rxpath(path_div)
Dim main_path as DivTag = rxp
Dim child_atag As Ranorex.ATag = main_path.FindSingle(Of Ranorex.ATag)("./div/div/table/tbody/tr/td/a[@InnerText='"+name.ToString+"']")
now i am getting an error as below for the line =======> Dim main_path as DivTag = rxp
System.NullReferenceException: Object reference not set to an instance of an object.
at Ranorex.Core.Path.LocationStep..ctor(ITree stepTree, RxPath owner)
at Ranorex.Core.RxPath.TryInit(String path)
--- End of inner exception stack trace ---
at Ranorex.Core.RxPath..ctor(String path)
Re: How to convert string to divtag
I did this but its showing the error
Value of type 'Ranorex.Core.RxPath' cannot be converted to 'Ranorex.DivTag'. (BC30311)
Dim rxp As RxPath = path_div
Dim div_path As DivTag = rxp
Dim child_atag As Ranorex.ATag = div_path.FindSingle(Of Ranorex.ATag)("./div........")
Value of type 'Ranorex.Core.RxPath' cannot be converted to 'Ranorex.DivTag'. (BC30311)
Dim rxp As RxPath = path_div
Dim div_path As DivTag = rxp
Dim child_atag As Ranorex.ATag = div_path.FindSingle(Of Ranorex.ATag)("./div........")
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to convert string to divtag
From your code I can't see where the path_div variable is defined; could it be that this variables is not defined or null? The following code is working for me, you just have to insert the right RanoreXPath to your DIV tag in the first code line:
Another hint: I guess that you have switched off the "Explicit" option in your VB project settings. If you switch the "Explicit" option on, you might get better error messages.
Regards,
Alex
Ranorex Team
Dim path_div as string ="your RanoreXPath to the DIV tag" Dim name as string="Asia" Dim divTag_adapter as DivTag = path_div Dim child_atag As Ranorex.ATag = divTag_adapter.FindSingle(Of Ranorex.ATag)("./div/div/table/tbody/tr/td/a[@InnerText='"+name.ToString+"']")Please, consider reading the Ranorex Tutorial! I posted the link to it in my last post and a link to the Ranorex User Guide.
Another hint: I guess that you have switched off the "Explicit" option in your VB project settings. If you switch the "Explicit" option on, you might get better error messages.
Regards,
Alex
Ranorex Team