Button is not clickable due to a span

2,765 views
Skip to first unread message

Long Hoàng Đình

unread,
Apr 21, 2016, 4:38:18 AM4/21/16
to Geb User Mailing List
Hello, 

I have a button that contains a span

<button id="button_07_1800002685" type="button" class=" htBlock-buttonPrimaryOut   htBlock-buttonS " onclick="onClickActionButton('action_07_1800002685');">
<span>Help registration</span>
</button>

Now I want to simulate a click on the button. This is the code I use:

$("#button_07_1800002685").click()

It yields an error:
org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (172, 606). Other element would receive the click: <span>...</span>

So I tried to click the span instead. 
$("#button_07_1800002685").find("span").click()

it yields the same error, the difference is just the click point:
org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (172, 608). Other element would receive the click: <span>...</span>

Please show me a way to click the button!

bolleypally vijay kumar

unread,
Apr 21, 2016, 5:07:16 AM4/21/16
to geb-...@googlegroups.com

Try moving mouse to you exact element and click
To do those actions please follow instructions of interact block in 4.15.3 in geb documentation

-from mobile

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/43a4ef9d-4a54-4551-b6e9-e94a5fd31f6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Long Hoàng Đình

unread,
Apr 21, 2016, 5:44:04 AM4/21/16
to Geb User Mailing List
Hi,

O followed the instruction at 4.15.3 of the book. This is the code:
                        interact {
clickAndHold($("#button_03_1800002685"))
moveByOffset(172, 608)
release()
}

It shows a new error:
geb.error.RequiredPageValueNotPresent: Template 'content template 'sendTimeRecorderUrl' defined by page.TimeRecorderSettingPage' returned null for args: '[]'

I also tried:
                        interact {
moveByOffset(172, 608)
$("#button_03_1800002685").click()
}
It shows the same error as before: org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (172, 606). Other element would receive the click: <span>...</span>

I think your suggestion is not appropriate because 4.15.3 of the book only shows how to do drag and drop. It doesn't show how to move to a point and click.

Dang Viet Ha

unread,
Apr 21, 2016, 5:49:51 AM4/21/16
to Geb User Mailing List
Try to use in FF, not in ChromiumDriver to confirm the problem? :)

bolleypally vijay kumar

unread,
Apr 21, 2016, 6:13:16 AM4/21/16
to geb-...@googlegroups.com
try this

def yourElement = $("#button_07_1800002685>span")
interact {
    moveToElement(yourElement)
    yourElement.click()
}


For more options, visit https://groups.google.com/d/optout.



--
Men who try to do something and Fail are infinitely better than those
who try to do nothing ...
                                                                                    B.VIJAY

Hoàng Đình Long

unread,
Apr 21, 2016, 6:17:42 AM4/21/16
to geb-...@googlegroups.com
thanks for your quick feedback, it still shows the same error but with different click point:
org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (321, 606). Other element would receive the click: <span>...</span>

--
You received this message because you are subscribed to a topic in the Google Groups "Geb User Mailing List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/geb-user/0mJDeOlaskQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to geb-user+u...@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
_Long HĐi_

bolleypally vijay kumar

unread,
Apr 21, 2016, 6:30:45 AM4/21/16
to geb-...@googlegroups.com
As for my understanding 
1-> span tag is in the button tag when we try to click on button it scolded us saying 'other element may receive the click'
2-> we tried to click on span instead of button after mouse move on it but this also started scolding so the last thing i left with is

use moveToElement(WebElement toElement, int xOffset, int yOffset) instead of moveToElement(yourElement)

all the best fingers crossed


For more options, visit https://groups.google.com/d/optout.

Hoàng Đình Long

unread,
Apr 21, 2016, 6:41:48 AM4/21/16
to geb-...@googlegroups.com
Tried that. This is the code:

                        def notClickableElement = $("#button_03_1800002685>span")
interact {
moveToElement(notClickableElement, 172, 608)
notClickableElement.click()
}

It still shows the same error: org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (172, 608). Other element would receive the click: <span>...</span>

Anyway, thanks for your trying to help!


For more options, visit https://groups.google.com/d/optout.



--
_Long HĐi_

Brian Kotek

unread,
Apr 21, 2016, 10:37:23 AM4/21/16
to Geb User Mailing List
Is this element animated in some way? Is it moving or appearing at the point you're trying to click it? Sounds like Webdriver is attempting to click on the last position of the element that it knows about, but the element has already moved (so the old coordinates aren't correct any longer).

Hoàng Đình Long

unread,
Apr 21, 2016, 10:42:27 AM4/21/16
to geb-...@googlegroups.com

No, the element can't move. It's a time management software, serious business, so it's doesn't make sense creating an animated button that moves around.

Brian Kotek

unread,
Apr 21, 2016, 12:21:17 PM4/21/16
to Geb User Mailing List
OK, then is the element hidden and does it become visible as part of what the test is doing?

Dang Viet Ha

unread,
Apr 21, 2016, 12:29:08 PM4/21/16
to Geb User Mailing List
AFAIK, the button is invisible from the beginning then visible when click a menu. What is your idea @brian428

Brian Kotek

unread,
Apr 21, 2016, 12:47:06 PM4/21/16
to Geb User Mailing List
I've just seen this happen (where the click targets invalid coordinates) in cases where something is animating (such as a slide-down notification or an animated pop-up window). While the element location is changing, you can run into the case where trying to click it causes this error. By the time the click is attempted, the element has already moved, so the coordinates being targeted are no longer current.

One way to confirm this is to add a sleep() call just before the click attempt, to make the test wait for a few seconds. If that works, you know the problem is that something is changing the element position and it's taking some time for the location to become stable.

Dang Viet Ha

unread,
Apr 21, 2016, 1:03:26 PM4/21/16
to Geb User Mailing List
Thank brian428, we will try your suggestion tomorrow. 

Hoàng Đình Long

unread,
Apr 21, 2016, 10:39:55 PM4/21/16
to geb-...@googlegroups.com
Hi Brian,

Did you mean Thread.sleep() or the other kind of sleep?
I tried Thread.sleep() but it didn't work. The same error:  
org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (172, 456). Other element would receive the click: <span>...</span>

Before that, I had tried waitFor(). No luck.


For more options, visit https://groups.google.com/d/optout.



--
_Long HĐi_

Hoàng Đình Long

unread,
Apr 21, 2016, 10:40:43 PM4/21/16
to geb-...@googlegroups.com
This is the code:

Thread.sleep(10000)
$("#button_03_1800002685").find("span").click()


For more options, visit https://groups.google.com/d/optout.



--
_Long HĐi_

Long Hoàng Đình

unread,
Apr 22, 2016, 12:12:40 AM4/22/16
to Geb User Mailing List
Actually, I do agree with you that the animation of the menu 'causes the problem (the button is hidden inside a menu, I have to click on the menu to make the button visible). The web app does have other buttons with span element inside the button but the button is still clickable (in this case, the button is not hidden inside a menu).

Now, I need to focus on solving this animation problem but still haven't got any clue.


On Thursday, April 21, 2016 at 11:47:06 PM UTC+7, brian428 wrote:

Dang Viet Ha

unread,
Apr 22, 2016, 11:43:39 AM4/22/16
to Geb User Mailing List
Dear Long,

Can you please re-produce the problem on your own static html to confirm that the problem come from the <span> inside a <button>?

Thank you
HaDV

Hoàng Đình Long

unread,
Apr 22, 2016, 11:47:13 AM4/22/16
to geb-...@googlegroups.com

Please read my answer to Brian! The problem comes from the animation.

Hoàng Đình Long

unread,
Apr 22, 2016, 11:49:55 AM4/22/16
to geb-...@googlegroups.com

I told him that the other buttons containing spans work fine. Only the ones inside a menu have the issue.

Dang Viet Ha

unread,
Apr 22, 2016, 12:30:01 PM4/22/16
to Geb User Mailing List
OK, I got it! Thank you!

Brian Kotek

unread,
Apr 22, 2016, 5:29:31 PM4/22/16
to Geb User Mailing List
The strange thing is that he said it still fails even if he sleeps before attempting the click? If it is animating, then waiting a second (or 5, or 10) and then attempting the click should work, since by that time any animation should have been completed.

Dang Viet Ha

unread,
Apr 22, 2016, 10:36:54 PM4/22/16
to Geb User Mailing List
> Thread.sleep(10000)
> $("#button_03_1800002685").find("span").click()

What if use the button click() instead of span click()? :)

Hoàng Đình Long

unread,
Apr 22, 2016, 10:38:50 PM4/22/16
to geb-...@googlegroups.com

I always try both cases. The same error.

Dang Viet Ha

unread,
Apr 22, 2016, 10:43:13 PM4/22/16
to Geb User Mailing List
I remember that in the selenium have a function to check the an item is present or not on the page. Maybe, we will try this way in Geb?

Hoàng Đình Long

unread,
Apr 22, 2016, 10:44:58 PM4/22/16
to geb-...@googlegroups.com

Okay, I'll try that and tell you later.

Dang Viet Ha

unread,
Apr 24, 2016, 1:25:33 AM4/24/16
to Geb User Mailing List
And one more way we can try is to using FF plugin to record the script by using the website manually, then we can know how selenium handle this animation.

Sujata Dwivedi

unread,
Apr 25, 2016, 7:16:48 AM4/25/16
to Geb User Mailing List
Hi ,

 Please try below two ways to perform click on button check button id should not be dynamic.


<button id="button_07_1800002685" type="button" class=" htBlock-buttonPrimaryOut   htBlock-buttonS " onclick="onClickActionButton('action_07_1800002685');">
<span>Help registration</span>
</button>


with above code you can try in two ways:
 $(button#button_07_1800002685).click()
or

$("span" , text:'Help registration').click()

Hoàng Đình Long

unread,
Apr 25, 2016, 7:54:20 AM4/25/16
to geb-...@googlegroups.com
Hi Sujata, 

I have just tried both of your methods. They produced the same error:
org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (172, 608). Other element would receive the click: <span>...</span>

--
You received this message because you are subscribed to a topic in the Google Groups "Geb User Mailing List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/geb-user/0mJDeOlaskQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
_Long HĐi_

Sujata Dwivedi

unread,
Apr 25, 2016, 10:00:50 AM4/25/16
to geb-...@googlegroups.com

Can u give me url n that info of the button u want to click?

And i want to know weather the id is generated dynamically?Can u plz chk  

Anyways i wll try some other way..wll let u know once i wll resolve that error

Hoàng Đình Long

unread,
Apr 25, 2016, 10:07:49 AM4/25/16
to geb-...@googlegroups.com

Hi Sujata,

Thank you for trying to help. The app is my customer's product. I am forbidden to provide any information such as password or links ( you need to login to see it).

Anyway, I am sure that the id is not dynamically generated. Everytime I refesh the page, it remains the same. Even if it were automatically generated (in fact, it's not), how come it showed the same error? If it were automatically generated, the element wouldn't be found and the error should be different.

Sujata Dwivedi

unread,
Apr 25, 2016, 10:15:07 AM4/25/16
to Geb User Mailing List
Okk this type of error comes when more than one element is having same id or dynamic id and some time due to scroll issue element is not clickable try scrolling also

Hoàng Đình Long

unread,
Apr 25, 2016, 10:30:49 AM4/25/16
to geb-...@googlegroups.com

Okay, I will notice that and try again tomorrow morning. Thanks!

On Apr 25, 2016 9:15 PM, "Sujata Dwivedi" <suja...@gmail.com> wrote:
Okk this type of error comes when more than one element is having same id or dynamic id and some time due to scroll issue element is not clickable try scrolling also

--
You received this message because you are subscribed to a topic in the Google Groups "Geb User Mailing List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/geb-user/0mJDeOlaskQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.

Long Hoàng Đình

unread,
Apr 27, 2016, 7:42:02 AM4/27/16
to Geb User Mailing List
Hello,

I am encountering this error more and more often. 
So I am in doubt that this is the fault of Google Chrome WebDriver. 
I am changing to FF to see if the problem persists but I am having a new problem with FF secure connection.
I post another thread here:
Please help!

Brian Kotek

unread,
Apr 27, 2016, 9:30:07 AM4/27/16
to Geb User Mailing List
I think we're at the point where you need to create an isolated, runnable test case that demonstrates the problem and send it out to the list (or post it to the Github issue tracker). We've got over 30 messages at this point, so it's doubtful that anyone can offer much more without seeing a demonstrable test case.

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.

Hoàng Đình Long

unread,
Apr 27, 2016, 9:33:48 AM4/27/16
to geb-...@googlegroups.com

Okay, I will do that after testing on Firefox. Thank you!

You received this message because you are subscribed to a topic in the Google Groups "Geb User Mailing List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/geb-user/0mJDeOlaskQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to geb-user+u...@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.

Long Hoàng Đình

unread,
May 5, 2016, 1:00:17 AM5/5/16
to Geb User Mailing List
Hello everyone,

I am having a workaround here. Instead of trying to click the button, I send a keystroke to it. In this case, I sent an enter key to it.

$("button#button_03_1800002685") << Keys.chord(Keys.ENTER)

This workaround works on Firefox. It change the browser to the next page. But it doesn't work on Chrome.

However, on Firefox, after changing the browser page, it produced this error:
org.openqa.selenium.StaleElementReferenceException: Element not found in the cache - perhaps the page has changed since it was looked up

I implemented the PageChangeListener to see if the page has changed. And the result is the page didn't changed after the button had been sent the keystroke. 

My question is: how can I change the page after sending the keystroke? I tried using the page() method to change the page but it didn't work. It shows the same error:
org.openqa.selenium.StaleElementReferenceException: Element not found in the cache - perhaps the page has changed since it was looked up

Please help! Many thanks!

Brian Kotek

unread,
May 5, 2016, 1:53:53 AM5/5/16
to Geb User Mailing List
Again, you're going to need to create a simple, reproducible test that demonstrates the problem. We've already had 35 messages on this, so without something for others to actually look at, a solution isn't going to magically appear.

Hoàng Đình Long

unread,
May 5, 2016, 2:23:09 AM5/5/16
to geb-...@googlegroups.com

Hi Brian,
This case is different because I already have a work around. I just want to ask how I can change a page after sending a keystroke to a button. Obviously, the button changed the page after being sent the key stroke but Geb doesn't detect the change.

You received this message because you are subscribed to a topic in the Google Groups "Geb User Mailing List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/geb-user/0mJDeOlaskQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to geb-user+u...@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages