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 in Java??

AkshadaAkshada Members
edited November -1 in Sahi - Open Source
Hi All,

How do i tell sahi to press "Enter key" in Java ??

Thanks and regards,
Akshada

Comments

  • AkshadaAkshada Members
    I tried this : browser.execute("_sahi._keyPress(_sahi._image('Search'), [13,13]);");

    But its not working!!
  • narayannarayan Administrators
    An enter can not pressed on an image. Use a textbox (or any input element) to execute that keypress event.
  • Hi Narayan,

    I tried using a "Textbox". That doesnot work!!
    Is there any other way in JAVA to do this??

    Thank you very much for the help!!

    Regards,
    Akshada
  • Hi,

    Is there any other way for "Enter Key" Keypress in JAVA??

    Thanks in advance!!
    Regards
    Akshada
  • narayannarayan Administrators
    Hi Akshada,

    Can you specify how you tried with a textbox? If you say something does not work, please do post what you tried so that we can verify and reproduce it here.

    Regards,
    Narayan
  • Hi Narayan,

    I did I tried this : browser.execute("_sahi._keyPress(_sahi._textbox('SearchInput'), [13,13]);");
    I'll take care of this next time!!

    Thank you!
    Regards,
    Akshada
  • narayannarayan Administrators
    Hi Akshada,

    We checked this and looks like pressing enter using keypress 13 does not work if the element does not have an explicit keypress handler.
    You can try this instead:

    browser.execute("_sahi._textbox('SearchInput').form.submit()");

    This is a workaround, till we figure out a better solution.

    Regards,
    Narayan
  • HI Narayan,

    There was this functionality which allowed User to use "Tab" and "Enter" keys which i wanted to automate.
    Otherwise i am able to record and playback the same. Issue was with "Enter key" and "Tab Key"

    Thank you for the help!! :-)
    Regards
    Akshada
  • mohanmohan Members
    edited August 2011
    I am also facing the same issue . but i found a workaround for me _blur is working in where i need to tab ,or i am using the mouse click where i want to enter and using the explict wait to load the data from db ... its working fine for me where i need to enter and tab .
  • AkshadaAkshada Members
    edited August 2011
    Hi All,

    Theres a "search" functionality avalaible in my application, So its like A text-box where u enter your keyword and a search image . On entering keyword and clicking on the Searck image, i should get valid results.

    Also if User entersKeyword and presses "Enter-Key" (No clicking on "Search image"), Valid results should be displayed. Which is what i want to test using Java!!

    Thanks and regards
    Akshada
  • hi...

    i'm testing a system in php that a user cannot input letters or special characters, it can only accept numbers...

    onkeypress='javascript: return isNumberKey(event);'


    but using sahi, automation, the system can accept the other characters...

    WHAT SHOULD I DO?

    help me pls...
    tnx...
  • Hi Narayan,

    As you mentioned, pressing enter using keypress 13 does not work if the element does not have an explicit keypress handler. You suggested browser.execute("_sahi._textbox('SearchInput').form.submit()");
    How can I achieve the same thing using sahi script? Is there anyway to submit the form?

    Looking forward for a quick reply, since I have a demo scheduled tomorrow morning :(

    Thanks a ton in advance.

    Regards,
    PRasad
Sign In or Register to comment.