Reputation: 65
In my unit test, I am unable to access dom element from shadow root.
var el = fixture('basic');
var imgElement = el.shadowRoot.querySelector('img');
I am getting null in imgElement. How to get the img element? I have tried also,
var imgElement2= document.querySelector('img');
Upvotes: 1
Views: 341
Reputation: 51
you have to use the setup
function first
suite('test', function(){
setup(function () {
my-el = fixture('DefaultElement');
});
Upvotes: 0
Reputation: 3441
If you are trying to access the dom element in the shadow root. Try ;
this.$.<element-id>
or
this.shadowRoot.querySelector(selector) / ie:('#element-id')
Upvotes: 0