Convert Key Sequence

Class library usage, coding and language questions.
Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Convert Key Sequence

Post by Hermch » Thu May 26, 2011 7:31 am

Hi,

I am new here and have an issue concerning Usercode in Ranorex.
I recorded a Key Sequence in ranorex which gets its data from a datasource. It is a variable with the string: "gct233\administrator". This String is then entered into a login field in Firefox.

Is it possible to convert this Key Sequence somehow, so that the string is directly entered into the field i want to have it in. If the method Key Sequence is used, there is always some "delay" for entering every single char.
I would like to have the whole string entered at once...

Here is the Usercode Ranroex generated:
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Drawing
Imports System.Threading
Imports System.Windows.Forms

Imports Ranorex
Imports Ranorex.Core
Imports Ranorex.Core.Testing

Namespace GUI_Admin

	Public Partial Class Recording1

		''' <summary>
		''' This method gets called right after the recording has been started.
		''' It can be used to execute recording specific initialization code.
		''' </summary>
		Private Sub Init()
			' Your recording specific initialization code goes here.
		End Sub

        Public Sub Key_Sequence_TextBenutzername_1()
            ' Your code goes here. Code inside this method will not be changed by the code generator.
            Report.Log(ReportLevel.Info, "Keyboard", "Key sequence 'gct233{LControlKey down}{RMenu down}{OemOpenBrackets}{LControlKey up}{LControlKey up}{RMenu up}{LControlKey up}administrator' with focus on 'TextBenutzername_'.", repo.TextBenutzername_Info, new RecordItemIndex(-1))
            repo.TextBenutzername_.PressKeys("gct233{LControlKey down}{RMenu down}{OemOpenBrackets}{LControlKey up}{LControlKey up}{RMenu up}{LControlKey up}administrator")
        End Sub

	End Class
End Namespace
I hope you can understand what I mean... :D

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Convert Key Sequence

Post by Support Team » Thu May 26, 2011 10:29 am

Hi,

You can use following two properties.
These methods depends on the control you want to automate.
If it is a text box use this property
http://www.ranorex.com/Documentation/Ra ... tValue.htm
and if it is an InputTag this property
http://www.ranorex.com/Documentation/Ra ... gValue.htm

Regards,
Peter
Ranorex Team
.
Image

Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Re: Convert Key Sequence

Post by Hermch » Fri May 27, 2011 8:10 am

Hi,

Thanks for your answer. Could you please post me a code example of how to use:

Code: Select all

public virtual string TagValue { get; set; }
I want to add my string "gct233\administrator" into the login field in firefox and internet explorer as username.

Thanks and regards.
Christian

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Convert Key Sequence

Post by Support Team » Fri May 27, 2011 10:39 am

Hi,

Here is a short sample:
Host.Local.OpenBrowser("http://www.w3schools.com/tags/tryit.asp ... orm_submit", "IE");               
InputTag inputFirstName = "/dom[@domain='www.w3schools.com']//form/input[@name='FirstName']";
InputTag inputLastName = "/dom[@domain='www.w3schools.com']//form/input[@name='LastName']";
inputFirstName.TagValue = "Donald";
inputLastName.TagValue = "Duck";
Regards,
Peter
Ranorex Team
.
Image

Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Re: Convert Key Sequence

Post by Hermch » Fri May 27, 2011 12:35 pm

I tryed it with textvalue and the following error is reported in rxlog:

Setting attribute 'text' failed on element '{Text:Benutzername:}'. The operation is not supported. The method or operation is not implemented.
Show Stacktrace
at Ranorex.Core.Element.SetAttributeValue(String name, Object value) at Ranorex.Core.Element.SetAttributeValue(String name, String value) at Ranorex.Text.set_TextValue(String value) at GUI_Admin.GUI_Admin.Recording1.Key_Sequence_TextBenutzername_1() in C:\Users\hermch\Documents\Ranorex\RanorexStudio Projects\GUI_Admin\GUI_Admin\Recording1.UserCode.vb:line 35 at GUI_Admin.GUI_Admin.Recording1.Run() in C:\Users\hermch\Documents\Ranorex\RanorexStudio Projects\GUI_Admin\GUI_Admin\Recording1.vb:line 78 at Ranorex.Core.Testing.TestSuiteModule.RunInternal(DataContext parentDataContext)


My Code looks like this:

Code: Select all

        Public Sub Key_Sequence_TextBenutzername_1()
            ' Your code goes here. Code inside this method will not be changed by the code generator.
            Report.Log(ReportLevel.Info, "Keyboard", "Key sequence 'gct233\administrator' with focus on  'TextBenutzername_'.", repo.TextBenutzername_Info, new RecordItemIndex(-1))
            repo.TextBenutzername_.TextValue = "gct233\administrator"
        End Sub
Do you have another idea for me? :?:

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Convert Key Sequence

Post by Support Team » Fri May 27, 2011 1:06 pm

Hi,

Please post me a Ranorex Snapshot for this control and I will write you an example for your textbox.
How to create a Ranorex Snapshot
Thank in advance.

Regards,
Peter
Ranorex Team
.
Image

Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Re: Convert Key Sequence

Post by Hermch » Fri May 27, 2011 2:22 pm

Hi,

to which email adress should i post the snapshot file?

Thanks and Regards

Chritian

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Convert Key Sequence

Post by Support Team » Fri May 27, 2011 4:22 pm

please post it to [email protected] and add a link to this forum entry.

Regards,
Roland
Ranorex Support Team
.
Image