1

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');

enter image description here

D.P
  • 65
  • 6

2 Answers2

0

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')
Cappittall
  • 3,300
  • 3
  • 15
  • 23
0

you have to use the setup function first

   suite('test', function(){
                setup(function () {
                my-el = fixture('DefaultElement');
            });