naazneen3264
naazneen3264

Reputation: 315

unable to get sendKeyEvent method in appium-android

In my appium-code, on using swipe, scroll methods and executing the code. Getting the below exception.

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)

And I don't see the SendKeyEvent method in the auto suggest dropdown. When I am manually typing SendKeyEvent(), it's throwing an error as undefined in the type AndroidDriver.

Attached screenshot SendKeyEvent method unavilable

Can anyone let me know please ?

Upvotes: 1

Views: 6798

Answers (3)

totbatot.ammo
totbatot.ammo

Reputation: 1

This code worked for me:

AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
driver.pressKeyCode(AndroidKeyCode.HOME);

What is supported? What is obsolete? How to find answer to these questions? Can someone please direct to reference???

Upvotes: -2

Marin Vasvari
Marin Vasvari

Reputation: 59

If you use java client 3.2.0 then you should try using pressKeyCode(keyCode) method instead of sendKeyEvent(keyEvent). Hope it helps.

Upvotes: 4

Kristaps Mežavilks
Kristaps Mežavilks

Reputation: 595

Of course, because this method is not for the driver. You can send keys to the element, not the driver. The solution would be following:

WebElement element = driver.findElement(By.id("the_id"));
element.sendKeys("necessary_text");

Upvotes: 0

Related Questions