Reputation: 945
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..:)
Upvotes: 4
Views: 11147
Reputation: 161
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.
Upvotes: 1
Reputation: 1810
There are instances when Wait Until Element Is Enabled
and Wait Until Element Is Visible
will return true but the element will still not be clickable, because it is hidden/overlapped by another element.
I can repoduce this situation in my app. An error I get is:
ElementClickInterceptedException:
Message: element click intercepted:
Element <button>...</button> is not clickable at point (169, 286). Other element would receive the click: <div></div>
There doesn't seem to be any "smart" solution without writing an external library. For now, the best way is to use this:
*** Keywords ***
Click Element Wait
[Arguments] ${locator}=required ${timeout}=2 ${mustWait}=False
Wait Until Element Is Visible ${locator} ${timeout}
Wait Until Element Is Enabled ${locator} ${timeout}
Run Keyword If $mustWait == True Sleep 1s
Click Element ${locator}
Use it like this:
Click Element Wait myButton 4 True # Wait until element is visible & enabled, then another 1 second as well
Click Element Wait myButton # Just wait until element is visible & enabled
Upvotes: 0
Reputation: 373
How about:
wait until element is visible ${UPDATE}
mouse down ${UPDATE}
mouse up ${UPDATE}
Worked for me for some weird acting elements..
Upvotes: 0
Reputation: 692
I am using the following approach.
Use the following keywords:
Wait Until Keyword Succeeds Page Should Contain Element ${Xpath}
Click Element ${Element}
This will help you to avoid using sleeps
in your testcases.
Upvotes: 0
Reputation: 2107
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.
Upvotes: 1