-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent behavior between elementWithin and someElementWithin #105
Comments
I do not agree. When I expect one If you need first element you should use It is unexpected behavior for |
Following this logic I cannot agree with you because to me selectors are not assertions. For example If a part of my test is to assert that there is one and only one element for the specified selector, I will assert it explicitly. And it will be explicitly stated in my test, and everyone who read it would understand what is the assertion. Especially when we are talking about selecting "some" element. Even semantically it does not imply any failure. Juts give me "some" if you have, or "none" if you don't. Don't fail because you have a lot, it is illogical, just give me some :) |
Canopy is not only a framework for testing but also for web automation. For example, I want to login to the system, I need to find editbox for login and enter user name there. I am pretty sure that it should be one input element, otherwise my selector is wrong or something changed in system. In this case script should be stopped with error. In this case, explicit check will double or even triple the size of scripts. Such behavior will add overhead in automation scripts. |
Exactly. It is a testing framework and it is up to you how you write your test selectors. It is about what you test. If you test that there should be only one element for the specified selectors, if that is your business logic - then yes, test it. Explicitly. It is good to see that you now agree with me about consistency of First, I don't see how it triples size of your tests. Even if you really want to assert uniqueness every time you call It just should not be a default behavior because not everyone needs it, and not everywhere. I believe you also don't need it everywhere if you look at my example above :) Yes, I could implement my own To make thing consistent either I prefer the last, as it less destructive, introduces less breaking changes and - in my opinion - more logical. But let's see what the author thinks and how he makes it :) I can live with both, as soon as everything is consistent. |
Interesting read =). Sergey is the author of elementWithin and someElement #73 so I don't want to break his use cases. I do agree though that they need to be consistent, and 2 of 3 work one way, and 1 works the other way. Sergey would it be acceptable if I made all 3 not throw exception if there is > 1 element, but added a configuration that would make all 3 throw an exception for > 1 element. That way all 3 can be consistent with either style? |
I agree that they need to be consistent. Also I want to have an option when they throw exception when >1 element. |
I think I will just make a configuration handle it for now. We can always review/change if it does not work out. |
I don't mind this option) |
This is now available on nuget, package 0.8.5 |
Closing, please let me know if you would like any more similar changes! |
elementWithin
returns the first element that satisfies selector, whilesomeElementWithin
fails if there is more than one element can be found by the specified selector.Expected behavior for
someElementWithin
:When one element found -> Some element
When more than one element found -> Some (first element)
When no elements found -> None
The text was updated successfully, but these errors were encountered: