This is a migrated thread and some comments may be shown as answers.

How to enter Ctrl-A

1 Answer 200 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
kwee
Top achievements
Rank 1
kwee asked on 14 Feb 2012, 09:17 PM
Hi,

I am using WebAii 2011.1.

I want to send the key Ctrl-A to the framework element that I found.

According to the documentation:
   1) SendString is deprecated in favor of TypeText or KeyPress
   2) TypeText cannot send special characters

No sure how to use KeyPress for 2 keys that are simultaneous, ControlKey and the "A" key.

I tried this sequence but it did not work ( ie select all of the text in Framework Element )

   fe.User.KeyDown(Keys.ControlKey);
   fe.User.KeyPress(Keys.A,Constant.KeyDelay);
   fe.User.KeyUp(Keys.ControlKey);


The only article I could find uses SendString.
   http://www.telerik.com/automated-testing-tools/community/forums/test-studio-express/automation-framework/can-t-combine-shift-key-down-with-other-keys.aspx

Thanks,

1 Answer, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 15 Feb 2012, 06:08 PM
Hello Kwee,

That is the correct code to simulate a Ctrl+A command from the keyboard. I think it's expected behavior for the "select all" keyboard command to select all of the text within the element (if the cursor is focused  within it).

If you're trying to simply visually highlight the element during execution, use the code below. More information of the FrameworkElement object can be found here.

//Highlight framework element
fe.Highlight();
 
//Clear highlighting
fe.Highlight(true);

If you're trying to accomplish something different, please provide more detail.

Kind regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
kwee
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Share this question
or