Ranorex

Role.Text

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet
View previous topic :: View next topic  
Author Message
sahoko



Joined: 09 Oct 2007
Posts: 9

PostPosted: Tue Oct 09, 2007 6:27 pm    Post subject: Role.Text
I'm unable to enter text to a text box. The spy tells me the element is the role type "Text". My code below finds the element, but its State is always "ReadOnly". I think that's why I can't enter text to this text box, but I don't know why it's flagged as "ReadOnly" to begin with...

// enter username
foreach (Control control in form.Controls)
{

Element objUserName = control.Element.FindChild(Role.Text, "User Name:");

// this conditional gets hit twice
// the text attached to the text box is also recognized as this obj
if (objUserName != null)
{
Console.WriteLine("trying to type the username");
Console.WriteLine(objUserName.State);


objUserName.Value = "System";

Application.Sleep(2000);
//break;
}
}
Back to top
View user's profile Send private message
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 435

PostPosted: Tue Oct 09, 2007 6:58 pm    Post subject:
Please try the following:

Code: click into code to enlarge
Element textbox = control.Element.FindChild(Role.Text, "UserName");
Mouse.ClickElement(textbox);
Application.SendKeys("Name");

This will set the focus to the textbox and enter the text "Name".

Jenö
Ranorex Support Team
Back to top
View user's profile Send private message Visit poster's website
sahoko



Joined: 09 Oct 2007
Posts: 9

PostPosted: Tue Oct 09, 2007 7:04 pm    Post subject:
Thanks for your solution. It worked. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum