Ranorex

Element.Select(TakeFocus) not working

 
Post new topic   Reply to topic    Ranorex Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
grahama



Joined: 24 Apr 2007
Posts: 8

PostPosted: Fri May 11, 2007 6:45 pm    Post subject: Element.Select(TakeFocus) not working
I have a login dialog with edit boxes for a username and password. The element information from RanorexSpy is

Role:Client, Name:"User name:"
Role:Client, Name:"Password:"

My code is as follows:

Code: click into code to enlarge
Element win = ... the login dialog ...
Element user = win.FindChild(Role.Client, "User name:");
Element pass = win.FindChild(Role.Client, "Password":);
user.Select(Selection.TakeFocus);
Application.SendKeys("bob");
Application.Sleep(100);
pass.Select(Selection.TakeFocus);
Application.SendKeys("secret");


But when the ranorex app runs, it enters both "bob" and "secret" into the username edit box. Nothing is entered into the password edit box.

I've printed the element location and size for user and pass and the values are correct.

How do I force an element to take the focus?

Thanks
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Fri May 11, 2007 8:11 pm    Post subject:
Normally you use the control class in a login dialog:

Code: click into code to enlarge
TextBox UserNameCtrl = form.FindTextBox("ctlText1");
TextBox PasswordCtrl = form.FindTextBox("ctlText2");

UserNameCtrl.Text = "text1";
PasswordCtrl.Text = "text2";


The Element.Select function works only within a control (ListView, TreeView,...), but doesn't activate an other control.
You can click into the element to activate it:

Code: click into code to enlarge
Element user = UserNameCtrl.Element;
Element pass = PasswordCtrl.Element;

Mouse.ClickElement(user);
Application.SendKeys("bob");

Mouse.ClickElement(pass);
Application.SendKeys("secret");


Jenö
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> Bug Reports 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