Page 1 of 1

Keyboard.Press

Posted: Wed Nov 07, 2012 10:31 pm
by omayer
Nothing happenned when using following code, trying tab down to the control Keyboard.Press("{TAB}");
Delay.Ms(2000);

Keyboard.KeyDown("{RETURN}");
Delay.Ms(2000);

Re: Keyboard.Press

Posted: Wed Nov 07, 2012 10:37 pm
by Ciege
Instead of a Keyboard.KeyDown("{RETURN}"); use Keyboard.Press("{ENTER}");

Re: Keyboard.Press

Posted: Wed Nov 07, 2012 10:46 pm
by omayer
thank you Ciege, will try pressEnter

Re: Keyboard.Press

Posted: Thu Nov 08, 2012 9:23 pm
by omayer
same result, not getting control move by using tab or Enter

Re: Keyboard.Press

Posted: Thu Nov 08, 2012 9:45 pm
by Ciege
Does it move when you use TAB manually?
Do you have focus set to the AUT AND to an existing control where TAB order would make sense?

Re: Keyboard.Press

Posted: Thu Nov 08, 2012 9:52 pm
by omayer
If i TAB manually it moves but when i try automate it doesn't , here is the method i am using

Code: Select all

public void CheckedWFH(string _wfh)
       {
       	if(_wfh=="Yes")
       	{
      	
       	 bool found = false;
  
       		
           	WebDocument webDocument = "/dom[@page='index.cfm']";    	
        	InputTag  findWfh; 			
			found = webDocument.TryFindSingle("/dom[@page='index.cfm']//input[@Id='chkWorkFromHome']", 50000, out findWfh);

				if (!found)  
				{  
				    throw new Ranorex.ElementNotFoundException("WFH checkbox was not found", null);                  
				} 
				
				else
				{ 		         
					
					findWfh.EnsureVisible();
					findWfh.PerformClick();
					Delay.Ms(5000);
					Keyboard.Press("{TAB}");
					Delay.Ms(2000);
					
					Keyboard.Press("{ENTER}");
					Delay.Ms(2000);
					
				}
				
       	}
       	
  }

Re: Keyboard.Press

Posted: Thu Nov 08, 2012 10:17 pm
by Ciege
So according to your code you find the element findWfh.
If it is found you click on the element findWfh.
Does the above two steps work? Did you click on the input element?

Are you sure that a single TAB from that point is proper to move to the next item you want highlighted?
Is any item getting highlighted? Maybe your tab is not making it to the proper item because of tab order or number of tabs needed.
Why are you using TAB anyway? Why not just click on the element? Can you find the element?
Please make sure the exact steps you have coded are the steps you perform manually.

Also, change your PerformClick to a Click and PerformClick does not move the mouse and actually click the element. Instead it just send the click action to the element.

Re: Keyboard.Press

Posted: Thu Nov 08, 2012 10:45 pm
by omayer
Thank you Ciege, after changing PerformClick to a Click now able to click on OK and continue the step. Thank you Again