webdriver - click() does not return after clicking on a button that disables after the click.

500 views
Skip to first unread message

Lisa Mercedes

unread,
Mar 17, 2014, 7:37:45 PM3/17/14
to seleniu...@googlegroups.com

I'm using Selenium WebDriver to test a page that suppose to load a page after clicking on the save button. 
This button has a javascript that disables it upon click, so the users won't click it more than once.

Upon checking in firebug, the locator id is correct. No issues with that. Also, the click does work on others buttons that are not disable after the click.

Has anyone faced a similar issue? Any help would be apprecaited!


DongXiang

unread,
Mar 19, 2014, 5:13:09 AM3/19/14
to seleniu...@googlegroups.com
Can you confirm does the javascript be triggered when you perform click on that element?

sometime, click not trigger "onclick" javascript event, it depends on what element it is. but you can fire a javascript onclick event on this element via webdriver.

Hope it can help you.

Best Regards,
--david


Date: Mon, 17 Mar 2014 16:37:45 -0700
From: mercede...@gmail.com
To: seleniu...@googlegroups.com
Subject: [selenium-users] webdriver - click() does not return after clicking on a button that disables after the click.
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/8817cf45-5ef4-43fd-adbd-e7ed98900c58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lisa Mercedes

unread,
Mar 19, 2014, 1:23:52 PM3/19/14
to seleniu...@googlegroups.com
David, Thank you for your help.

The javascript was executed since the javascript onclick changes the save button from enable to disable.
Somehow it did not return after the driver.Click(), I'm getting an exception error timeout.

When I tested it manually as the user will do,  the save button works ok.

function onSubmitClick(button) {
  var isValid = IsValidForm();
  if (isValid) {
       button.disabled = true;
       button.className += " _state_disabled";
       button value = $ ('#subtext'). val();
       button.form.submit();
    }
   return isValid;
}

The javascript code is as follow:

    <div class = "footerButton">
          <input id="save" class="button" type="submit" onclick="onSubmitClick(this);" value="Save">
     </div>

Regards,
-Mercedes

DongXiang

unread,
Mar 20, 2014, 5:39:10 AM3/20/14
to seleniu...@googlegroups.com
Hi 

Do you mean the javascript don't return? could you copy your codes and exception back?

As I know, send javascript onclick event to a div or other elements, if it trigger an alert or other modal dialog,

the webdriver will hang under IE? not fully understand why webdriver hang here. 

looks your onSubmitClick function, it seems the form will be submitted, I guess your web page will re-loading or navigate to the other page. WebDriver will block here when an action trigger a web page re-loading or navigation, like click a button to submit the form and page navigate to the other page, but I am not sure does javascript also has this feature, if it has this feature, could you check the loading of next web page after you send javascript event, if the loading never done or very slow, I guess your webdriver will hang here.

Best Regards,
--david


Date: Wed, 19 Mar 2014 10:23:52 -0700
From: mercede...@gmail.com
To: seleniu...@googlegroups.com
Subject: Re: [selenium-users] webdriver - click() does not return after clicking on a button that disables after the click.
Reply all
Reply to author
Forward
0 new messages