--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To post to this group, send email to selenium-...@googlegroups.com.
To unsubscribe from this group, send email to selenium-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-developers?hl=en.
Instead of a NO-OP, I'd rather prefer the above to happen. The user
does eventually "realize" that the element is disabled when nothing
happens. So it is visual feedback and translating that to code, I'd
expect some sort of "realization" or "feedback" that the element is
indeed disabled & the click is going to do nothing.
--aditya
element.click();
with a call to
void selectElement(WebElement element) {
element.click();
if (!element.isSelected()) {
throw ... or fail() or ...;
}
}
unfortunately, 90% of that 90% won't know that this is what they want.
(Also, adding boilerplate)
When we provided such a method, not throwing made a lot more sense
(though IIRC we didn't do so), but now that clicking is the only
interaction we have with WebElements, that feedback is important.
One option is to consider both cases: having WebElement.click support
the test author and the advanced user interactions support closer
emulation of the user. A second option is to always emulate the user,
and the third option is to make it easier for test authors.
We're going with option 2: it's consistent with our views of almost
emulating the user where possible. Testers who want to verify that
elements are enabled can do so using by firing "element.isEnabled"
first. If we'd gone the other way of always throwing an exception, the
legitimate tests of verifying behavior when clicking on disabled
elements (few though they are) would have been impossible. Option 1 is
just plain ugly (even if it was the one that I originally thought we'd
go for)
All drivers now implement this behavior.
Simon
> Today on IRC a discussion was started on what should happen when we
> click on disabled elements. Currently we will get an error
> "InvalidElementStateException" when this happens.
>
> I am of the opinion that clicking on a disabled element should be a NO-OP
> since we are trying to emulate what a user sees and feels. A user won't
> get an exception thrown when they click on a disabled element. There was
> also a view that we should notify the calling code that it tried to use
> a disabled element.
From a web browser vendor's point of view, we need to be able to click
disabled elements. We are using WebDriver for testing the browser itself,
and it may well happen that there is a bug with the disabled code making
a disabled button behave in an inappropriate way.
Currently we've added a flag in OperaDriver that we switch on for our
internal
tests.
However, on a more general level, I don't think that WebDriver should make
these
kinds of decisions on “logic” for the user. If the user tells WebDriver
to click
something, WebDriver should in my opinion just do so without actually
performing
a check on whether the element is enabled or not first; that's not what I
asked
it to do.
We obviously have to agree on some kind of compromise between convenience
and
just relaying what the user asks us to with no concern whatsoever of what
happens:
WebDriver.navigate().to() is a good example of this.
In the case of clicking a disabled element, however, the user might wish
to check
that clicking a disabled button doesn't actually trigger an event.
> Time to round off this discussion. The problem is, we're trying to
> focus on the user. The question is, which user? The person we're
> modeling interacting with the browser? Or the test author?
>
> One option is to consider both cases: having WebElement.click support
> the test author and the advanced user interactions support closer
> emulation of the user. A second option is to always emulate the user,
> and the third option is to make it easier for test authors.
>
> We're going with option 2: it's consistent with our views of almost
> emulating the user where possible.
Question: How is not allowing the user to click a disabled button
emulating user behaviour? A user _will_ (and more importantly _can_)
click disabled elements. Why won't WebDriver do this for me when I tell
it to?
> Testers who want to verify that elements are enabled can do so using
> by firing "element.isEnabled" first.
That is probably fine in the 90% case. In the case of actual emulation
(i.e. testing a web browser) we want to make sure that no bad stuff happens
if you did indeed happen to press the disabled button.
Things to consider: What would happen if there is a JavaScript event tied
to the disabled button overriding its disabledness qualities? What if the
browser has a bug that crashes or triggers an error if you click the
disabled
button?
Option 2 was to be consistent with the user: we allow clicks on
disabled elements. Option 3 (making it easy for test authors) would
have meant not allowing clicks on disabled elements.
>> Testers who want to verify that elements are enabled can do so using
>> by firing "element.isEnabled" first.
>
> That is probably fine in the 90% case. In the case of actual emulation
> (i.e. testing a web browser) we want to make sure that no bad stuff happens
> if you did indeed happen to press the disabled button.
>
> Things to consider: What would happen if there is a JavaScript event tied
> to the disabled button overriding its disabledness qualities? What if the
> browser has a bug that crashes or triggers an error if you click the
> disabled
> button?
And that's exactly the sort of reasoning that means that lead us to
make the choice we did :)
Simon
Simon
Simon
Simon
This is a good point, that's what caused my initial confusion reading
Dave's replies.
Thanks for clarifying this, I must have misunderstood your first post.
(-:
That's my fault. When I put NOOP I should have said that it should act _essentially_ like a NOOP because throwing an exception isn't what people would expect.
David