Unable to click on a <div href="#"> HTML button


I am testing an Android Hybrid application using the latest Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
On the login screen, I am able to sendkeys to the username and password input HTML elements. However, I am unable to click on the login button which is defined as:

  <div href="#" id="loginbutton" class="button">Login</div>

Note that I am able to call loginButton.getText() and getTagName()… Which means that I am able to locate the

HTML element but I cannot click it.

This is how the HTML page reads

<div id="formbody">
      <div class="line">
            <input placeholder="Username" type="text" id="username" class="styled_input" value="">
       <div class="line">
            <input placeholder="Password" type="password" id="password" class="styled_input" value="">
       <div class="line_button">
            <div href="#" id="loginbutton" class="button">Login</div>

And this is my code:


    WebElement userNameTextField = appiumDriver.findElement(By.id("username"));
    userNameTextField.sendKeys(new String[]{username});
    WebElement passwordTextField = appiumDriver.findElement(By.id("password"));
    passwordTextField.sendKeys(new String[]{password});
    WebElement loginButton = appiumDriver.findElement(By.id("loginbutton"));

I would “really” appreciate if anyone can shed some light on why I am unable to click on the



Hi Did you got any resolution for the above issue please let me know…

have you tried find element by class?

xpath works for me for buttons.

I posted the same question on Stackoverflow here: http://stackoverflow.com/questions/27475834/unable-to-click-on-a-div-href-html-element-using-appium-androiddriver-in-w
In there, I mentioned the workaround I used which is switching from hybrid to native
I found that when it comes to performing clicks and what not, you need to switch to native

Can you post the exact code that you used based on the code I provided in my question? Were you able to click on the login div using xpath while you are in “hybrid mode”?

@Salem_Artin ;
should work. Do you know the website link which your hybrid app points to? If yes, open the site in chrome and inspect element. It will give you exact xpath.