Send keys with "\n" not working on iOS

Hi there,

We have selenium based tests for desktop browser and we are converting scripts to support execution on mobile browsers. We use browserstack to execute tests

Issue we are facing is need to enter text in text input field and hit enter key, below is the code that we are using

webelement.sendkeys(“text to enter”+"\n")

Above code is working fine on Android devices but not on iOS

We are using NodeJS as the programming language

Could someone please let me know how to achieve same functionality in iOS

Try one of these options, I don’t remember which one is for iOS

webelement.sendkeys(“text to enter”+ Keys.ENTER)
– or –
webelement.sendkeys(“text to enter”+ Keys.RETURN)

Thanks JD, I tried with both on iOS but none of them are working.

Able to achieve using Javascript.

var e = jQuery.Event(‘keydown’); e.which = 13; $(’#ElementID’).trigger(e);var e = jQuery.Event(‘keydown’); e.which = 13; $(’#cityFinder’).trigger(e);

MobileElement.sendKeys(Keys.RETURN) is working on iOS. But it takes much time to execute. Any other alternatives or any solution to decrease the time?

Have you tried:

webelement.sendKeys(StringEscapeUtils.unescapeJava("text to enter\n"));