title: NoSuchElementError: no such element: Unable to locate element for protractor
body: <blockquote>
  <p>element(By.xpath((&quot;/html/body/div[2]/div[3]/md-content/md-card/md-card-content/div/div/div/div/md-custom-table/div/md-table-container/table/thead/tr/th[3]/span&quot;))).click();</p>
  </blockquote>
  <p>This is the code I want to make it work.</p>
  <p>This isxpath path of where I want to be clicked</p>
  <blockquote>
  <p>/html/body/div[2]/div[3]/md-content/md-card/md-card-content/div/div/div/div/md-custom-table/div/md-table-container/table/thead/tr/th[3]/span</p>
  </blockquote>
  <p>This is the error</p>
  <pre><code>Message:
    Failed: No element found using locator: By(xpath, /html/body/div[2]/div[3]/md-content/md-card/md-card-content/div/div/div/div/md-custom-table/div/md-table-container/table/thead/tr/th[3]/span) Stack:
    NoSuchElementError: No element found using locator:
    By(xpath, /html/body/div[2]/div[3]/md-content/md-card/md-card-content/div/div/div/div/md-custom-table/div/md-table-container/table/thead/tr/th[3]/span)
      at WebDriverError (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:26:26)
      at NoSuchElementError (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:241:26)
      at /usr/lib/node_modules/protractor/built/element.js:717:27
      at ManagedPromise.invokeCallback_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1379:14)
      at TaskQueue.execute_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
      at TaskQueue.executeNext_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
      at /usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2775:27
      at /usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
      at process._tickCallback (internal/process/next_tick.js:103:7)Error
      at ElementArrayFinder.applyAction_ (/usr/lib/node_modules/protractor/built/element.js:403:27)
      at ElementArrayFinder._this.(anonymous function) [as click] (/usr/lib/node_modules/protractor/built/element.js:101:30)
      at ElementFinder.(anonymous function) [as click] (/usr/lib/node_modules/protractor/built/element.js:740:22)
      at Object.&lt;anonymous&gt; (/home/vegan/hb-productupload/gateway/src/test/javascript/e2e/account/productDashboard/productDashboardControllerSpec.js:36:47)
      at /usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:94:23
      at new ManagedPromise (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1082:7)
      at controlFlowExecute (/usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:80:18)
      at TaskQueue.execute_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
      at TaskQueue.executeNext_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
      at /usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2820:25
    From: Task: Run it(&quot;should be able to check product dashboard as a cta&quot;) in control flow
      at Object.&lt;anonymous&gt; (/usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:79:14)
      at /usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:16:5
      at ManagedPromise.invokeCallback_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1379:14)
      at TaskQueue.execute_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
      at TaskQueue.executeNext_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
      at /usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2775:27
    From asynchronous test: 
    Error
      at Suite.&lt;anonymous&gt; (/home/vegan/hb-productupload/gateway/src/test/javascript/e2e/account/productDashboard/productDashboardControllerSpec.js:33:9)
      at Object.&lt;anonymous&gt; (/home/vegan/hb-productupload/gateway/src/test/javascript/e2e/account/productDashboard/productDashboardControllerSpec.js:8:1)
      at Module._compile (module.js:413:34)
      at Object.Module._extensions..js (module.js:422:10)
      at Module.load (module.js:357:32)
      at Function.Module._load (module.js:314:12)
  
  1 spec, 1 failure Finished in 13.16 seconds
  
  [15:19:25] I/launcher - 0 instance(s) of WebDriver still running
  [15:19:25] I/launcher - chrome #01 failed 1 test(s)
  [15:19:25] I/launcher - overall: 1 failed spec(s)
  [15:19:25] E/launcher - Process exited with error code 1
  </code></pre>
  <p>So for same place, this is html:</p>
  <pre><code>&lt;span translate=&quot;&quot; class=&quot;ng-scope ng-binding&quot;&gt;Number of Products&lt;/span&gt;
  </code></pre>
  <p>This is the selector</p>
  <pre><code>body &gt; div.site-content &gt; div.layout-column.flex &gt; md-content &gt; md-card &gt; md-card-content &gt; div &gt; div &gt; div &gt; div &gt; md-custom-table &gt; div &gt; md-table-container &gt; table &gt; thead &gt; tr &gt; th.md-column.ng-scope.ng-isolate-scope.flex.md-sort.md-active &gt; span
  </code></pre>
  <p>For same span, this can click</p>
  <pre><code> dashboardPageObject.element.all(by.css('[md-order-by=&quot;count&quot;]')).get(1);.click();
              browser.driver.sleep(28);
              dashboardPageObject.element.all(by.css('[md-order-by=&quot;count&quot;]')).get(1);.click();
  </code></pre>
  <p>It clicks 2 times but it does not wait 28 seconds.</p>
  <p>I don't care selector for the xpath or css. For example for another</p>
  <pre><code>/html/body/div[2]/div[3]/header/md-content/md-tabs/md-tabs-wrapper/md-tabs-canvas/md-pagination-wrapper/md-tab-item[5]/span
  </code></pre>
  <p>This works</p>
  <pre><code> element(by.xpath('/html/body/div[2]/div[3]/header/md-content/md-tabs/md-tabs-wrapper/md-tabs-canvas/md-pagination-wrapper/md-tab-item[5]/span'));
  </code></pre>