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.

_keyPress() does not work for enter

JulianBJulianB Members
edited September 2011 in Sahi - Open Source
Hello,

I'm trying toget my sahi script to press enter.
I have found the following solutions in the forums and documentation:
_keyPress(_textbox("__ac_name"), 13);
_keyPress(_textbox("__ac_name"), [13,13]);

Unfortunately the both don't work (and yes the textbox accessor is correct). What can I try instead?

OS: Windows XP
Browsers: Mozilla Firefox 6.0.2 and PhantomJS 1.1.0
Sahi Build: 2011-07-19

Regards,
Julian

Comments

  • Hi Julian,

    keypress 13 does not work if the element does not have an explicit keypress handler.

    Here is an example :
    _navigateTo("http://www.google.com");
    _setValue(_textbox("q"),"Sahi testing tool");
    _keyPress(_textbox("q"),13);
    

    Let me know if you face any problem

    Regards
    Sumitra
  • Okay, the example works. For me, that makes it all the more confusing.

    The textbox where I try to "press" enter is in a form element.

    Most Browsers have a specific behaviour when you press enter in a form. I have changed this behaviour using a jQuery function. And I want to test if it works.
    To be honest, I don't have any idea what an explicit keypress handler is, so I'm guessing, the element doesn't have one...

    Could you please give me some pointer on how to proceed?

    Thank you!
    Regards,
    Julian
Sign In or Register to comment.