-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add a reasonable way to get DOM elements from page-objects #475
Comments
@NullVoxPopuli I believe, exposing an under-the-hood DOM element is a violation of the basic page object idea to abstract an implementation from the test. Typically when you change implemetation, you just want to update related page object, but all the related tests untouched, and that's one of the goals of the page objects. As far as I can see, most of the |
then ember-cli-page-object needs assertions.: -\ as is, doing Like, |
Yes, it does, but "qunit-dom" still doesn't seem to be a solution. Let's assume, you have: const page = create({
hasSomeState: hasClass('someState')
}) "qunit-dom" would not allow us to use this |
then, it may be easiest, philosophically, to implement a:
so that way, we could have an error message like:
|
Exactly! A while ago I've made a quick poc for this https://github.com/ro0gr/ember-qunit-page-object, and in general, this direction looks promising to me. Unfortunately I still don't have enough time to renew my efforts there, but we made a step on the that direction some time ago. In ec-page-object, we now have |
I just found this: https://github.com/ro0gr/ember-qunit-page-object/blob/master/tests/smoke-test.js all of that is very similar to qunit-dom, but requires all the assertions to be wrapped in an arrow function provided to |
I don't think |
I think it was just a single test, but you can find another tests w/o |
what about integrating with qunit-dom?
assert.dom(page.object.subObject).hasText('some text'); I think this is doable if getPageObjectDefinition allows access to a selector (non-jquery selector) or element |
I'd like to delegate that assertions api somewhere, but
I think it isn't achievable via a single CSS selector string. For example, there is no reliable way to get a nested collection element via single CSS selector. The best I can think of is some kind of query DSL object, which would contain nested Also, I'm not sure if the knowledge about the page objects should be a "qunit-dom" responsibility 🤔 |
that's all qunit-dom needs. the page object can provide the element or collection.
I think it's better than re-inventing qunit-dom for page objects? less to maintain overall, imo |
I'd say, it gets inspiration from qunit-dom( FWIW, I think, you can achieve |
@ro0gr what if under the hood of QUnit.assert.po(pageObject) {
return this.dom(pageObject.element);
} |
@yratanov I think this is a perfect answer to a question "how to integrate", with that we don't even need to expose QUnit.assert.po(pageObject) {
return this.dom(findOne(pageObject));
} However, in scale, integration of these 2 libs has a number of pitfalls, like:
|
@ro0gr yep, I think you are right. Can I be any help with https://github.com/ro0gr/ember-qunit-page-object? |
@yratanov thanks! Glad to see you are interested. As far as I remember, there were some complexity in parsing page object instance shape(props) due to a lack of I'll try to renew my mind about this addon the next few days and create some tickets, in order to have some plan. |
@NullVoxPopuli what do you think? is the snippet, suggested by @yratanov, something you are looking for? |
maybe! would need to see it in action to really know what the implications are |
@NullVoxPopuli @ro0gr I've created a small addon for it https://github.com/yratanov/ember-page-object-asserts . It's very simple, my main goal was to make errors more descriptive. API has something in common with qunit-dom. const page = create({
link: {
scope: 'a',
href: attribute('href'),
isHighlighted: hasClass('highlighted'),
},
list: collection('li'),
input: { scope: 'input' }
});
assert.po(page.link).hasText("test");
assert.po(page.link).hasNoText("bla");
assert.po(page.link).hasText(/test/);
assert.po(page.link).has('href', 'google.com');
assert.po(page.link).has('isHighlighted');
assert.po(page.input).hasValue('test');
assert.po(page.input).isPresent();
assert.po(page.input).isHidden();
assert.po(page.list).hasItems(2); Please tell me what you think :) It's my first addon, so I might be messed something :) |
made few improvements to the addon, now you can do this: const page = create({
link: {
scope: 'a',
href: attribute('href'),
isHighlighted: hasClass('highlighted'),
}
});
assert.po(page.link).href('google.com');
assert.po(page.link).isHighlighted(); Directly calling props as methods :) |
@yratanov I like it! Since this issue seems to be a bit unrelated to a custom assertions API, left some initial feedback at your addon repo yratanov/ember-page-object-asserts#1 |
Supersedes: #473
As mentioned here: #467 (comment)
there are other APIs in progress, but they seem very verbose.
Ideally, from a testing perspective we wouldn't need any additional imports:
that
dom
getter would be present on all page objects, regardless of single or multiple, so that we have a single, consistent API for use withqunit-dom
thoughts?
/cc @ro0gr, @Turbo87
The text was updated successfully, but these errors were encountered: