WebDriver.click() not working

5,038 views
Skip to first unread message

ChrisR

unread,
Jan 6, 2012, 5:31:25 PM1/6/12
to Selenium Users
I have, as part of my code the following :

// Use the driver to get the Login
def loginPage = server + "activity-management-ui/login/auth"
driver.get(loginPage)
driver.findElement(By.id("username"))
assert driver.getTitle() == "Login"

// Assert succeeds, confirmed I have the correct page

// Enter User name and password and click log in
driver.findElement(By.id("username")).sendKeys(username)
driver.findElement(By.id("password")).sendKeys(password)
driver.findElement(By.id("sign-in")).click()

The click does not seem to click the button at all. I have
implemented the WebDriverEventListener class to log the before and
after click actions, and can check that the element is found, and is
of the correct type. The click however doesn't submit the log in page
and log into the application. The HTML looks like :

<form class="test" action="/activity-management-ui/
j_spring_security_check" method="post">
<div class="clearfix">
<div class="clearfix">
<label for="password">Password</label>
<div class="input">
<input id="password" type="password" name="j_password">
<input id="sign-in" class="btn blue" type="submit" value="Sign In">
</div>
</div>

The before and after click show I am on the element I expect (the
submit), but the driver appears to go nowhere. This is not the only
page I am having trouble with the click() function not triggering the
web page to do something. Other pages also show the click() -
sometimes- not working. I spect some time checking that I have the
correct element, and that the element is active and available, but
still the click() does not always trigger a new page to open as
expected.

The system under test is a javascript based set of web pages using
ExtJS as the framework.

Liel Ran

unread,
Jan 9, 2012, 1:09:07 AM1/9/12
to seleniu...@googlegroups.com
did you try submit() ?



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Yeshwant Murali

unread,
Jan 9, 2012, 1:18:35 AM1/9/12
to seleniu...@googlegroups.com
Agree with Chris.
Also see if after entering the 'password', the login button enables or so. If yes, then you need to wait until the button is enabled, by using any assert / wait time.
To implement wait time use below code:
-------------------------------------------------------------------------------------------------------
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 20));
-------------------------------------------------------------------------------------------------------
Hope this helps.
 
Thank you,
Yeshwant

ChrisR

unread,
Jan 10, 2012, 12:44:47 PM1/10/12
to Selenium Users
I have 10 second implicit time out set on the driver. I also have
code that checks for the existence of the button and whether it is
enabled. Neither of these seem to solve the issue.

In other areas I am also having problems with the click not working,
and in these cases I am also checking for the link being enabled and
the underlying href element, and again in these cases the click does
not work.

On Jan 8, 10:18 pm, Yeshwant Murali <yeshwantkum...@gmail.com> wrote:
> Agree with Chris.
> Also see if after entering the 'password', the login button enables or so.
> If yes, then you need to wait until the button is enabled, by using any
> assert / wait time.
> To implement wait time use below code:
> --------------------------------------------------------------------------- ----------------------------
> driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 20));
> --------------------------------------------------------------------------- ----------------------------
> Hope this helps.
>
> Thank you,
> Yeshwant
>
>
>
>
>
>
>
> On Mon, Jan 9, 2012 at 11:39 AM, Liel Ran <liel.ran.m...@gmail.com> wrote:
> > did you try submit() ?
>

Yeshwant Murali

unread,
Jan 11, 2012, 12:18:50 AM1/11/12
to seleniu...@googlegroups.com
Sorry, I meant agree with Liel. As Liel said did you try submit()?
-Yeshwant

ChrisR

unread,
Jan 11, 2012, 12:01:44 PM1/11/12
to Selenium Users
Submit will work on the log in page. Obviously submit() doesn't work
on other clickable objects which aren't form based.

I did further testing and can confirm that click() in 2.16 is not
working where the same code running 2.14 does work (including the
above log in page form).

skd

unread,
Jan 11, 2012, 12:15:47 PM1/11/12
to seleniu...@googlegroups.com
I'm also having a problem with click() not working. Nothing happens when I execute click() on the following element:

<area nohref="nohref" onclick="selectPoint(this);" label="<p>Click the point to see more information below.</p>" id="0_0_area" coords="383,39,389,39,389,45,383,45,383,39,383,39" shape="poly" style="">

Neither driver.findElement(By.id("0_0_area")).click() nor selenium.click("0_0_area") works on this element. Clicking the element does work in the Selenium IDE 1.5.0.

I'm using 2.16.1 on Firefox 8.

ChrisR

unread,
Jan 11, 2012, 12:20:31 PM1/11/12
to Selenium Users
Have you tried with 2.14?

I -think- there's a fault on the click() in 2.16.

skd

unread,
Jan 11, 2012, 12:36:30 PM1/11/12
to seleniu...@googlegroups.com
I've tried with 2.15, which is the first version of WebDriver I've used.  I haven't tried with 2.14.

Rose

unread,
Jan 12, 2012, 12:11:12 AM1/12/12
to Selenium Users
Try driver.sendkyes("\n")

ChrisR

unread,
Jan 12, 2012, 12:40:22 PM1/12/12
to Selenium Users
This solution doesn't work on all areas that are clickable in a
webpage.

Terrence Turner

unread,
Jan 12, 2012, 5:08:58 PM1/12/12
to seleniu...@googlegroups.com
I can confirm that this is also not working with the selenium-webdriver 2.16 ruby gem as well. The webdriver appears to get the click message but does nothing with it and no errors are thrown. 

Chaminda

unread,
Jan 16, 2012, 5:59:45 AM1/16/12
to seleniu...@googlegroups.com
I had the same issue. This was because of the message that appeared on top of the firefox window in FF9 with the text "Will you help improve Mozilla Firefox by sending anonymous........ (yes) (no)". Get rid of this and the clicks work. I clicked "no" with my own profile, and used it in the tests. Click works now.

Nishant Mehta

unread,
Dec 23, 2013, 6:57:21 AM12/23/13
to seleniu...@googlegroups.com
I am still facing this issue unable to click even if the element is selected which i have verified by printing out the text of the button .Has anyone able to solve this i am using selenium 2.39.0??

Ramaguru N

unread,
Dec 24, 2013, 1:13:17 AM12/24/13
to seleniu...@googlegroups.com
did you try the element with CSS selector??

Regards,
Ramaguru N


On Mon, Dec 23, 2013 at 5:27 PM, Nishant Mehta <nishan...@gmail.com> wrote:
I am still facing this issue unable to click even if the element is selected which i have verified by printing out the text of the button .Has anyone able to solve this i am using selenium 2.39.0??

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

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

nani.thrinath.info

unread,
Dec 25, 2013, 11:51:40 AM12/25/13
to seleniu...@googlegroups.com
Try with CSS selector.

Thrinath


sumit kumar pradhan

unread,
Sep 6, 2018, 2:10:24 PM9/6/18
to Selenium Users
Please find the simple solution to resolve click event issue in selenium. [Click Command In Selenium Webdriver Does Not Work](https://www.skptricks.com/2018/09/click-command-in-selenium-webdriver-does-not-work.html)
Reply all
Reply to author
Forward
0 new messages