18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
Unable to simulate "ENTER/GO" on the ipad using _keyPress()
This snippet of code is not working trying to hit enter after entering a search query:
_setValue(_textbox(0), "");
_setValue(_textbox(0), $searchQuery);
_focus(_textbox(0));
_keyPress(_textbox(0), [13,13]);
I also tried without _focus and using _keyPress(_textbox(0), 13), but nothing has worked. Am I using the correct api or am I missing something?
Thanks in advance.
_setValue(_textbox(0), "");
_setValue(_textbox(0), $searchQuery);
_focus(_textbox(0));
_keyPress(_textbox(0), [13,13]);
I also tried without _focus and using _keyPress(_textbox(0), 13), but nothing has worked. Am I using the correct api or am I missing something?
Thanks in advance.
This discussion has been closed.
Answers
Simulating ENTER keypress using _keypress doesn't seem to work.
Although, please have a look at an alternate way for ENTER keypress event.
Please have a look at the following link. It should sovle your problem.
If you still have doubts though, please let me know.
Regards.
I looked at _setfile(2), and am not sure how to use it as I am not uploading a file. Here is what I would like to do:
1. Enter a search term in a search box (has no search button)
2. Hit enter to perform the search.
I think there has been a misunderstanding. I will make it more clear for you.
The following line of code in the script on the above link is what is needed to simulate the ENTER keypress event.
However this function isn't defined in Sahi OS so you'll need to add the following functions as well in your script:
This should make it work for you.
Please let me know if it doesn't.
Regards.
I'm emulating the ipad on FF as I can't get anything to run on the ipad (see my other thread).
Sorry for the confusion. Your other post was in the Sahi OS forum and not the Pro one, so I assumed that you required it to work with Sahi OS.
For Sahi Pro,
Use the following code statement to simulate a ENTER keypress event:
Let me know if it doesn't work for you.
Regards.
_setValue(_searchbox(0), $searchQuery); //this works
_focus(_searchbox(0));
_sahi._typeKeyCodeNative(java.awt.event.KeyEvent.VK_ENTER);
Please have a look at the following code:
I have added _focusWindow before you focus the searchbox element and also removed "_sahi." from the _typeKeyCodeNative API.
I have tested it taking textbox as the element and it works as required. However it should work for searchbox too.
Please let me know.
Regards.
Thanks anyway.
Please post the workaround here so that others who are facing a similar issue can also get it working for them.
Regards.