A very common problem people have while testing an ember application that uses the wonderful ember-wormhole addon is making the page objects to play nicely with it. In this blog post I’ll try to cover some of the problems and solutions regarding this.
A bit of context first, by default all page object properties lookups are done inside the Ember application’s container, this means that if you try to find an element in your tests through a page object, that search will be scoped by this container, so any element outside of it won’t be found.
As you may know, one of the characteristics of ember-wormhole is the ability to render a block of code outside the application container making it unreachable using the out-of-the-box properties of ember-cli-page-object.
Since version 1.3.0 ember-cli-page-object has built-in support to make it work well together, specially on acceptance tests.
As of this version, the restriction was overcome by a new option included on all page object properties, the
testContainer option which accepts a CSS selector to specify a different container on where to look for the DOM elements.
Lets see an example of how to use this.
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9
Let’s test this button using a page object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
As you can see in the page object definition, we want to click a button that is outside the application container so we tell the page object to look for the element on
Hope this clarifies a bit how to use ember-wormhole and ember-cli-page-object in conjunction. Any feedback on how to improve the integration of both addons is more than welcome!