title: Failed: Cannot read property 'click' of null in karma testing
body: <p>I am writing karma/jasmine test case for the click event, but I am getting null for button. Please suggest me. Thanks in Advance.</p>
  <pre><code>  it('should', async(() =&gt; {
      spyOn(component, 'clickMethod');
      let button = fixture.debugElement.nativeElement.querySelector('#view-rec');
      console.log(button); --&gt; button is null I am getting
      button.click();
      fixture.whenStable().then(() =&gt; {
          expect(component.clickMethod).toHaveBeenCalled();
      })
  </code></pre>
  <p>component::</p>
  <pre><code>  clickMethod() {
        this.msg.node.setVal(false);
        this.myBtn = &quot;Hello&quot;;
    }
  </code></pre>
  <p>Html::</p>
  <pre><code>&lt;mat-menu #menu=&quot;matMenu&quot; class=&quot;dropdown&quot;&gt;
    &lt;button mat-menu-item&gt;
    &lt;/button&gt;
    &lt;button mat-menu-item id=&quot;view-rec&quot;(click)='clickMethod()'&gt;   
    &lt;/button&gt; 
  &lt;/mat-menu&gt;
  </code></pre>