Android hybrid app - element seems to be clicked but in fact no action is performed

Hi All, I am facing issue in clicking on element. It is identifying the element but click operation is not getting performed.

I have used all the required capabilities, element with issue is as below,

WebElement loginbtn = driver.findElement(By.xpath("//button[@type=‘button’]"));
loginbtn.click();

Please suggest.

Are you certain that, in the DOM, the button element itself holds the click event? In the application that I test, the dev team tends to wrap buttons in a few extra div elements for style and then defines the click event in one of those div tag’s onClick= … Like in your case, if I select the actual button element but it has no click event defined in DOM, nothing happens… an example of xPath from my project that selects the button’s parent which has the actual click event…
“//button[text()=‘Done’]/…/…/…”

Good Luck!

Is this the first action you are performing through code ?

Is there any other button clickable so far through code or you just started ?

I can suggest something based on your response

Thanks
Saurabh

@Smitty: Thanks for your inputs. I tried using parent level but still i am not able to proceed further.

pagesourcecode() for ref -

Username
Password
Login
  • 1
    2
    3
    <
  • 4
    5
    6
  • 7
    8
    9
  • (+/-)
    0
    .
    Done

@Note: I am able to click the element manually. Verified below xpath,
WebElement loginbtn = driver.findElement(By.xpath("//div[text()=‘Login’]/…"));
//button[@type=‘button’]
//android.widget.Button
//button[@aria-label=‘LoginButton’]/…
loginbtn.click();

@jhaskumar: Before login I am trying to provide user credentials, which is working fine, directly through sendkeys() & even I am able to click on input field. code for username is as below,

WebElement username = driver.findElement(By.xpath("//input[@aria-label=‘UsernameField’]"));

Please suggest.

Username
Password
Login
  • 1
    2
    3
    <
  • 4
    5
    6
  • 7
    8
    9
  • (+/-)
    0
    .
    Done

Try using the Preformatted text modifier (the HTML tag looking button between the Quotes and Up Arrow) on your HTML … or wrap it in ticks …" ` " … so that our browsers show the raw code instead of trying to render it:

<div id="foo">
<ul>
<li></li>
</ul>
</div>

I still suspect that, while you are getting the element you are looking for, that element does not contain the click event that you need… But I would need to see the un-rendered HTML to confirm that…