This is a migrated thread and some comments may be shown as answers.

Checking a button for Disabled after jQuery

2 Answers 130 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 01 Dec 2010, 09:30 PM
Ok, I have a control based on the asp:Wizard control.

The last page of the wizard my jquery finds the finish button, then disables it so the user can't complete until something else on the page has occurred.

So this is what I was going for in my Coded test
HtmlInputSubmit FinishButtonSubmit = Pages.UndergradMedportalCa.FinishButtonSubmit;
            FinishButtonSubmit.Wait.ForExists(5000);
            FinishButtonSubmit.Wait.ForAttributes("disabled=disabled");

function checkSelectionCount() {
            var button = $('.finishbutton');
            var count = $('input[type="checkbox"]:checked', '.dailyevalStudent_container');
 
            if (count.length < 1) {
                button.attr('disabled', 'disabled')
            }
            else {
                button.removeAttr("disabled");
            }
 
            return count.length;
        }


Although this is what the input html is like in firefox
<input type="submit" class="finishbutton" id="FinishButton" value="Finish Evaluating Student" name="ctl00$content$dailyEvalForm$ctl02$FinishNavigationTemplateContainerID$FinishButton" disabled="">

I always timeout waiting for the attribute...and a debug on that step shows there's definatly no Disabled attribute

This is what the devtool in IE shows
<input name="ctl00$content$dailyEvalForm$ctl02$FinishNavigationTemplateContainerID$FinishButton" disabled="disabled" class="finishbutton" id="FinishButton" type="submit" value="Finish Evaluating Student"/>


Ideas?...am I doing it wrong?

What do you think the odds of getting a quickvalidation "IsDisabled" or "IsEnabled" (not just Visible\not visible)

2 Answers, 1 is accepted

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 01 Dec 2010, 10:09 PM
The idea is (if you look at the script)...the button enables itself when at least 1 checkbox is clicked...but I'm a tad stumped on how to test that button....
0
Accepted
Keaegan
Telerik team
answered on 02 Dec 2010, 07:55 PM

Hi Steve,

Try replacing your coded step with the following:

HtmlInputSubmit FinishButtonSubmit = Pages.UndergradMedportalCa.FinishButtonSubmit;
Button.Wait.ForExists(5000);
Wait.For<HtmlInputButton>(c => c.BaseElement.OuterMarkup.Contains("disabled"), Button, 10000);

That should allow you to simply search the Outer Markup to contain "disabled", and continue on after the "disabled" markup has been found. OuterMarkup usually has a better track record on locating the "disabled" attribute (due to different browsers implementing it differently, as you saw with firefox). While different browsers will handle the disabled attribute differently, all of them will have the word "disabled" at least once if an attribute is actually disabled. 

Conversely, you may also try modifying your following line:

FinishButtonSubmit.Wait.ForAttributes("disabled=disabled");

To read this instead:

FinishButtonSubmit.Wait.ForAttributes("disabled");

However, we would advise using our provided code for confirming the item is disabled. Please let us know if this setup does not perform better for you on this test. 

Regards,
Keaegan
the Telerik team

Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
Tags
General Discussions
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Keaegan
Telerik team
Share this question
or