18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Using _keyPress()

pankaj.nithpankaj.nith Members
edited November -1 in Sahi - Open Source
Hi,

Any idea how to use the key code directly in the function _keyPress() ?
i want to use keypress for "ENTER" and "ESCAPE" buttons.

Regards,
Pankaj.

Comments

  • StringyLowStringyLow Members
    edited July 2008
    I'm dealing with the same thing right now. I want to send PageUp/PageDown to a control on a page.

    I was thinking of using dispatchEvent but haven't had a chance to experiment with it yet. You want to play around with it and let me know what you come up with?

    http://developer.mozilla.org/en/docs/DOM:element.dispatchEvent
  • Hi,

    Thanks for the input. I will definitely try this and will revert with the results i get. :)

    Regards,
    Pankaj.
  • rksrks Members
    keycode for escape and enter keys are 27 and 13 respectively. I haven't tried but i guess passing these with _keyPress should do the job.
  • pankaj.nithpankaj.nith Members
    edited August 2008
    Ya, I had tried both. It worked for Enter but in case of Escape its throwing error.
    Also tried using dispatchevent thing (but in vain) but am not much conversant with jscript.

    Regards,
    Pankaj.
  • rksrks Members
    can you post the error you are getting in case of esacpe?
  • Ya. It says element has no properties.
    Actually I am trying to press Escape after waiting for the page to load for a certain period.
    the element that i pass to the _keyPress() function is top.document which is posing the problem, i suppose.

    Regards,
    pankaj.
  • rksrks Members
    Right coz the code in _keyPress() to extract value of the element passed and document object doesn't have a valid property called "value".
Sign In or Register to comment.