Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Element is not clickable at point - but it clicks in fact

My test is failing with:

WebDriverException: Message: unknown error: Element is not clickable at point (1 786, 183). Other element would receive the click: <'div align="right">...<'/div>

xpath I access is:

${UPDATE}    xpath=//button[@type='submit' and contains(text(),'Update')]

use in keyword:

    wait until element is visible   ${UPDATE}
    click element    ${UPDATE}

source:

<div align="right">
    <button type="submit" class="btn btn-primary ng-binding" ng-click="submitForm()" ng-disabled="updateDisabled">Update</button>
    <button type="button" class="btn btn-primary" ng-click="reset(projectForm)" ng-disabled="updateDisabled">Reset</button>
</div>

But the button is really clicked in the test -> data are saved - so it is OK. I just don't understand why it throws the exception when it clicked correctly and what can I do to make it pass..It is just obvious that it found the element and clicked on it...I also tried to use "wait until element is enabled" and "focus"... Thanks for any suggestion! PS: I added the character "'" to div element in exception, otherwise it was not displayed here..:)

like image 278
neliCZka Avatar asked Sep 02 '25 05:09

neliCZka


2 Answers

Although it is really bad practise to do this, I would recommend placing a couple of Sleep 1s keywords around your test case, for example:

Sleep    1s
Wait Until Element Is Visible   ${UPDATE}
Sleep    1s
Click Element    ${UPDATE}
Sleep    1s

Just to debug and make sure the driver isn't tripping over itself. (Which was the issue I was having) If this then works and passes, you will then need to basically wait longer than the button being active. Is there another section of the webpage which takes longer to load? If so use that.

But when you can, get rid of the Sleep 1s Key words as it is really bad practise.

like image 190
Goralight Avatar answered Sep 05 '25 00:09

Goralight


Richard's answer was very helpful but might not have been directly applicable for everyone. I had to customize it to my use case -

Wait Until Keyword Succeeds      5x     10s      Click Element   XPATH://<add xpath>

This would run the test 5 times with a 10s interval in between failures absolutely removing the need for any explicit sleeps to be made in the code. Both the values can be altered to suit you needs better. Note that the Wait Until Keyword Succeeds keyword can be used along with any operation including Input Text which means that if you change every line of your test case to use this, you can guarantee that your tests will pass irrespective of variations in response times of the website.

like image 33
Abhiram Natarajan Avatar answered Sep 05 '25 00:09

Abhiram Natarajan