Error when using Ranorex.Text

Class library usage, coding and language questions.
Poorvika
Posts: 1
Joined: Wed Feb 05, 2014 11:31 am

Error when using Ranorex.Text

Post by Poorvika » Wed Feb 05, 2014 11:50 am

Hello All,

I written the following function in VB.net to verify if a text box is present

Code: Select all

Public Function findTxtBox(IdentifierXpath As String, strTxt As String)

        Dim txtBox As Ranorex.Text
        Try
            Delay.Milliseconds(5000)
            txtBox = form.FindSingle(Of Ranorex.Text)(IdentifierXpath)
            'txtBox = Host.Local.FindSingle(Of Ranorex.Text)(IdentifierXpath) -----> I have also tried this
            If txtBox.Visible() = False Then
            	'throw an exception
            End If
            Catch ex As Exception
            	MsgBox("Exception : " & ex.ToString)
            End Try
        End Try
        
End Function
But i am getting the following exception

A first chance exception of type 'Ranorex.CapabilityNotSupportedException' occurred in Ranorex.Core.dll
Ranorex.CapabilityNotSupportedException: The element does not support the required capability 'text'.
at Ranorex.Adapter.Create[T](Element element)
at Ranorex.Adapter.FindSingle[T](RxPath path)


Please help!!!

Swisside
Posts: 92
Joined: Thu Oct 10, 2013 10:40 am

Re: Error when using Ranorex.Text

Post by Swisside » Fri Feb 07, 2014 9:57 am

Hello

Could you provide a snapshot of the element/repository so we can help you .

http://www.ranorex.com/support/user-gui ... files.html


That error means you are using Ranorex.Text where it cannot be used. There are a number of possible causes however.


Cheers

Swiss'
A simple thank you always does wonders !

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

Re: Error when using Ranorex.Text

Post by krstcs » Fri Feb 07, 2014 3:05 pm

I would guess that you are testing a website?

If so, then you need to use the object type TextTag instead of Text, since HTML objects are actually tags.

Change all of the Ranorex.Text calls to Ranorex.TextTag.

For example:
"Dim txtBox As Ranorex.TextTag"
Shortcuts usually aren't...

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: Error when using Ranorex.Text

Post by mzperix » Thu Apr 10, 2014 12:17 pm

Hi Poorvika,

The error message you get is because the element you want to create does not have the Capabilities of Text. As suggested by krstcs, you have to use another adapter. Note that there are no TextTag adapters, so you have to find another one:

To determine what kind of adapters can be attached to an element, just open the spy, and select the element. You will see the properties grouped by the different capabilities, like General, or Webelement.

Every adapter are required to have the proper capabilities available for that element. There are adapters are more general, like Webelement, and more specific, like TextAreaTag. These adapters have some hierarchy, which can be seen in API documentation:

http://www.ranorex.com/Documentation/Ra ... dapter.htm

The Adpater class is the base class of all adapters, you can see the inherited classes, those can be used as adapters. Note that the WebElement class contains the TextAreaTag.

Another easy method to determine what kind of adapters to use, is to look at xpath. The last item tells you what kind of adapters should be used.

For example, an xpath of /form/div/div/input should have the adapter of Ranorex.inputTag, whereas the
/form/element/element/control should have the Ranorex.Control adapter.

If you want to make sure, just use Ranorex.Element class:
http://www.ranorex.com/Documentation/Ra ... lement.htm
It has for example the visible property you need. If you want to do actions, that Element class does not have, then you can just attach an adapter for it of the specified type with the As(Of T As Adapter) As T method.

Hope this helps,

Best Regards,
Zoltán

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

Re: Error when using Ranorex.Text

Post by krstcs » Thu Apr 10, 2014 1:43 pm

Zoltan is correct. My apologies, I wasn't looking at what I wrote.

Check the path to the element and make sure that you are using the adapter that matches the path. It likely is an inputtag type. Also, webelement may be a better generic adapter for web testing.
Shortcuts usually aren't...