title: TypeError: Cannot read property 'click' of undefined Cypress
body: <p>I find button using code:</p>
  <pre><code>cy.get('[class=&quot;ng-select ng-select-multiple ng-select-searchable ng-untouched ng-valid ng-select-focused ng-select-opened ng-select-top ng-dirty&quot;]')
    .children('[class=&quot;ng-select-container ng-has-value&quot;]')
    .children('[title=&quot;Clear all&quot;]')
  </code></pre>
  <p>Then I do several actions - like click, check is visible etc. All that works if I have this code directly in the test file.</p>
  <pre><code>getClearObjectsButton() {
    cy.get('[class=&quot;ng-select ng-select-multiple ng-select-searchable ng-untouched ng-valid ng-select-focused ng-select-opened ng-select-top ng-dirty&quot;]')
      .children('[class=&quot;ng-select-container ng-has-value&quot;]')
      .children('[title=&quot;Clear all&quot;]')  
  }
  </code></pre>
  <p>However, if I use a secondary file with created functions I get an error as in the title.</p>
  <pre><code>register.getClearObjectsButton().click()
  </code></pre>
  <pre><code>cypress_runner.js:174495 TypeError: Cannot read property 'click' of undefined
      at Context.&lt;anonymous&gt; (tests?p=cypress\integration\create_user\check_objects_selector.js-106:580)
  </code></pre>
  <p>Any idea how to fix this issue?</p>