Hi All,
Does anyone know how to send texts into the textbox without using element? (When element not traceble)
Thanks
NU
Hi All,
Does anyone know how to send texts into the textbox without using element? (When element not traceble)
Thanks
NU
@nithizunnikumaran21
If you want to insert text using send text/send keys to a text box you should Define the element.
if you want to send keyboard actions you can able to do it without elements
by select the type as keys in the manual mode on a test case.
you can type into whatever field currently has focus without locating it. tap where the field is (Mobile.tapAtPosition) so the keyboard comes up, then:
android (uiautomator2):
def driver = MobileDriverFactory.getDriver()
driver.executeScript('mobile: type', [text: 'hello'])
older drivers that do not have mobile: type accept the same through adb: driver.executeScript('mobile: shell', [command: 'input', args: ['text', 'hello']]), needs the adb_shell insecure feature enabled on the appium server.
ios (xcuitest):
driver.executeScript('mobile: keys', [keys: ['h','e','l','l','o']])
or driver.getKeyboard().sendKeys('hello') which is the older appium way and still works in the java client katalon ships.
that said, “not traceable” usually just means the field is not in the page source at the moment you spy, do a Mobile.getAttribute on the parent or dump the source (driver.getPageSource()) after tapping, the EditText tends to be there once the keyboard is open.
Good answer @depapp . A few additions for @nithizunnikumaran21:
@Keyword
def typeIntoFocused(String text) {
def driver = MobileDriverFactory.getDriver()
if (driver instanceof io.appium.java_client.android.AndroidDriver) {
driver.executeScript('mobile: type', [text: text])
} else {
driver.executeScript('mobile: keys', [keys: text.toList()])
}
}
Mobile.delay(1) so it has focus and the keyboard is up before typing.adb shell input text, spaces must be sent as %s and special or unicode characters often fail, so prefer mobile: type where the driver supports it.