tag:blogger.com,1999:blog-581197352358126527.post632106652811063473..comments2024-03-28T00:32:25.959-07:00Comments on japh(r) by Chris Strom: Can't Even Polymer with Intern and Local Selenium ServerAnonymoushttp://www.blogger.com/profile/00135361916531185929noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-581197352358126527.post-85338935131102790572014-12-17T22:12:53.393-08:002014-12-17T22:12:53.393-08:00Cool! Saves me the trouble of having to figure it ...Cool! Saves me the trouble of having to figure it out and write it up myself. Thanks :)Anonymoushttps://www.blogger.com/profile/00135361916531185929noreply@blogger.comtag:blogger.com,1999:blog-581197352358126527.post-59471753320060717522014-12-17T09:00:00.539-08:002014-12-17T09:00:00.539-08:00Thanks Chris.
For future references I summarized...Thanks Chris. <br /><br />For future references I summarized my experience in a blog post: http://mmxgroup.net/2014/12/16/testing-a-google-polymer-project-using-internjs/Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-581197352358126527.post-61936775171337917422014-12-16T17:31:28.642-08:002014-12-16T17:31:28.642-08:00Yup, I use Polymer.whenReady() in the book for tes...Yup, I use Polymer.whenReady() in the book for testing as well. Unfortunately, webdriver does not grant access to the Polymer top-level object (as best I can tell). Without it, that doesn't work :(Anonymoushttps://www.blogger.com/profile/00135361916531185929noreply@blogger.comtag:blogger.com,1999:blog-581197352358126527.post-50701068871539509612014-12-16T17:29:38.343-08:002014-12-16T17:29:38.343-08:00Yup, that sounds similar to what I wound up doing ...Yup, that sounds similar to what I wound up doing in Protractor (another webdriver testing tool): http://japhr.blogspot.com/2014/12/protractor-can-test-polymer-sort-of.html. <br /><br />I begin to think that webdriver-based tools are not appropriate for testing Polymer, mostly because of the inability to access the shadow dom (but for other reasons as well).Anonymoushttps://www.blogger.com/profile/00135361916531185929noreply@blogger.comtag:blogger.com,1999:blog-581197352358126527.post-86518641913933962722014-12-16T16:10:18.321-08:002014-12-16T16:10:18.321-08:00Web Component Tester uses Polymer.whenReady() to w...Web Component Tester uses Polymer.whenReady() to wait till polymer has done all its microtasks. May be you can try it out. I have internjs on my to learn list still –Anonymoushttps://www.blogger.com/profile/13105828677930405991noreply@blogger.comtag:blogger.com,1999:blog-581197352358126527.post-1803645687441372322014-12-16T14:34:28.733-08:002014-12-16T14:34:28.733-08:00Thanks Chris. I came up with some thing which work...Thanks Chris. I came up with some thing which works but it is pretty ugly. <br /><br />You have to return whatever you want to test in the `pollUntil` function. It wraps it in a Promise and in the `then` part you could grab the value and do the assert. <br />The sad part is returning the element itself won't work as you will get the same: <br /><br /> stale element reference: element is not attached to the page document<br /><br />So in case of your code it would be something like this:<br /><br />'': function () {<br /> return this.remote<br /> .get(require.toUrl('../index.html'))<br /> .setFindTimeout(5000)<br /> .findByXpath('//body[not(@unresolved)]')<br /> .then(pollUntil(function () {<br /> if (document.querySelector("x-pizza").shadowRoot) {<br /> return document.querySelector("x-pizza").shadowRoot.querySelector("nested-x-pizza").id;<br /> }<br /> return null;<br /> }, [], 1000))<br /> .then(function (pizzaId) {<br /> assert.equal(pizzaId, 'expectedValue');<br /> }, function (err) {<br /><br /> });<br />}<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-581197352358126527.post-28817737593651096862014-12-15T15:16:24.313-08:002014-12-15T15:16:24.313-08:00Even in Firefox, the Polymer element has a shadowR...Even in Firefox, the Polymer element has a shadowRoot property (even if it's not a hasOwnProperty). The test is accessing it as a regular property, so I don't know why it would behave differently in Chrome. Still, I'll be sure to give it a try.<br /><br />Glad you were able to get it working!Anonymoushttps://www.blogger.com/profile/00135361916531185929noreply@blogger.comtag:blogger.com,1999:blog-581197352358126527.post-26402841781951460922014-12-15T14:55:13.389-08:002014-12-15T14:55:13.389-08:00Hello Chris,
Thanks for the great write up about ...Hello Chris,<br /><br />Thanks for the great write up about Intern and Polymer. It helped me get up and running with Intern to test Polymer. <br /><br />In your case it should be related to the fact that custom elements do not have 'shadowRoot' in FireFox as it has not yet been implemented in FireFox. There are some Polyfills to do the job. So even manually in the console the following would return `false`: <br /><br />```<br />var pizza_elements = document.getElementsByTagName('x-pizza');<br />pizza_elements[0].hasOwnProperty('shadoRoot'); // Returns false in FireFox, return true in Chrome<br /><br />```<br /><br />Remove FireFox from the environments and see how it works. Then you would be able to adopt the tests accordingly.<br /><br />Thanks for the great blog posts, they have been very helpful. Keep up the great work.<br />Anonymousnoreply@blogger.com