appium-for-mac icon indicating copy to clipboard operation
appium-for-mac copied to clipboard

sendKeys(Keys.TAB) or Keys.ENTER etc doesn't work in Appium for MAC

Open navinjoy opened this issue 11 years ago • 5 comments

Hi Dan,

I have the below simple code for TextEdit in OSX and its currently doesn't work the way it suppose to for Keyboard events Keys.TAB, Keys.ENTER.

I am not quite sure where's the issue is? whether its with sendKeys() method or the Keyboard events. Can you please have a look at the same.

import java.net.MalformedURLException; import java.net.URL;

import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver;

public class TextEdit {

public static void main(String[] args) throws MalformedURLException, InterruptedException {


    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setPlatform(Platform.MAC);
    WebDriver appdriver = new RemoteWebDriver(new URL("http://localhost:8080/wd/hub"), capabilities);
    appdriver.get("TextEdit");

    WebElement textArea = appdriver.findElement(By.xpath("//AXTextArea[@AXRole='AXTextArea']"));
    textArea.sendKeys("Hello World");
    Thread.sleep(2000);
    textArea.sendKeys(Keys.TAB);
    Thread.sleep(2000);
    textArea.sendKeys("*******");
    appdriver.quit();

}

}

navinjoy avatar Nov 13 '13 07:11 navinjoy

Does your app have any hidden text field under the text area?

sangeethasriniv avatar Mar 04 '14 17:03 sangeethasriniv

Thank you for the response.

There are no hidden text fields and they are Dojo controls.

Regards Navin

Sent from my iPhone

On Mar 4, 2014, at 9:26 AM, Sangeetha [email protected] wrote:

Does your app have any hidden text field under the text area?

Reply to this email directly or view it on GitHubhttps://github.com/appium/appium-for-mac/issues/6#issuecomment-36650241 .

navinjoy avatar Mar 05 '14 18:03 navinjoy

Hi Navin, First of all please try to use this url when creating your remotedriver http://127.0.0.1:4622/wd/hub That being said, I think the special key code is not handled properly on the server side. A fix might be needed.

fangmobile avatar Jul 07 '14 18:07 fangmobile

I wonder if it is possible to use seleniums action class to send enter or tab key...

miksch123 avatar May 15 '20 07:05 miksch123

@navinjoy After reading the code and trying, I found this send_keys("\uE007") works for ENTER

Wizr avatar Nov 16 '20 07:11 Wizr