title: Error locating element using Protractor - Failed: script timeout: result was not received in 20 seconds
body: <p>I have a very basic website developed in Angular 6 and I am trying to write some e2e tests for it. But the first script itself is giving me a hard time. I am getting the following error -</p>
  
  <pre><code>C:\Users\user\Documents\workspace-vs-code\protractor-poc&gt;protractor
  [18:25:12] I/launcher - Running 1 instances of WebDriver
  [18:25:12] I/direct - Using ChromeDriver directly...
  [14500:21224:0129/182513.778:ERROR:configuration_policy_handler_list.cc(91)] Unk
  nown policy: PasswordManagerAllowShowPasswords
  [14500:21224:0129/182513.866:ERROR:configuration_policy_handler_list.cc(91)] Unk
  nown policy: PasswordManagerAllowShowPasswords
  
  DevTools listening on ws://127.0.0.1:58686/devtools/browser/22a05a0a-e850-47e3-b
  a7b-fecc6ed97ac8
  Jasmine started
  (node:20576) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmp
  dir() instead.
  
    service catalog search
      x should login
        - Failed: script timeout: result was not received in 20 seconds
          (Session info: chrome=71.0.3578.98)
          (Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53
  f3f74387),platform=Windows NT 6.1.7601 SP1 x86_64)
          (Session info: chrome=71.0.3578.98)
          (Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53
  f3f74387),platform=Windows NT 6.1.7601 SP1 x86_64)
            at Object.checkLegacyResponse (C:\Users\user\AppData\Roaming\npm\no
  de_modules\protractor\node_modules\selenium-webdriver\lib\error.js:546:15)
            at parseHttpResponse (C:\Users\user\AppData\Roaming\npm\node_module
  s\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
            at doSend.then.response (C:\Users\user\AppData\Roaming\npm\node_mod
  ules\protractor\node_modules\selenium-webdriver\lib\http.js:441:30)
            at process._tickCallback (internal/process/next_tick.js:68:7)
        From: Task: Protractor.waitForAngular() - Locator: By(css selector, *[id="
  password"])
            at Driver.schedule (C:\Users\user\AppData\Roaming\npm\node_modules\
  protractor\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
            at ProtractorBrowser.executeAsyncScript_ (C:\Users\user\AppData\Roa
  ming\npm\node_modules\protractor\built\browser.js:425:28)
            at angularAppRoot.then (C:\Users\user\AppData\Roaming\npm\node_modu
  les\protractor\built\browser.js:456:33)
            at ManagedPromise.invokeCallback_ (C:\Users\user\AppData\Roaming\np
  m\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1376:14
  )
            at TaskQueue.execute_ (C:\Users\user\AppData\Roaming\npm\node_modul
  es\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14)
            at TaskQueue.executeNext_ (C:\Users\user\AppData\Roaming\npm\node_m
  odules\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27)
            at asyncRun (C:\Users\user\AppData\Roaming\npm\node_modules\protrac
  tor\node_modules\selenium-webdriver\lib\promise.js:2927:27)
            at C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_m
  odules\selenium-webdriver\lib\promise.js:668:7
            at process._tickCallback (internal/process/next_tick.js:68:7)Error
            at ElementArrayFinder.applyAction_ (C:\Users\user\AppData\Roaming\n
  pm\node_modules\protractor\built\element.js:459:27)
            at ElementArrayFinder.(anonymous function).args [as isDisplayed] (C:\U
  sers\user\AppData\Roaming\npm\node_modules\protractor\built\element.js:91:29)
  
            at ElementFinder.(anonymous function).args [as isDisplayed] (C:\Users\
  user\AppData\Roaming\npm\node_modules\protractor\built\element.js:831:22)
            at UserContext.&lt;anonymous&gt; (C:\Users\user\Documents\workspace-vs-co
  de\protractor-poc\e2e\app.servicecatalogsearch.ts:17:44)
            at step (C:\Users\user\Documents\workspace-vs-code\protractor-poc\e
  2e\app.servicecatalogsearch.ts:32:23)
            at Object.next (C:\Users\user\Documents\workspace-vs-code\protracto
  r-poc\e2e\app.servicecatalogsearch.ts:13:53)
            at C:\Users\user\Documents\workspace-vs-code\protractor-poc\e2e\app
  .servicecatalogsearch.ts:7:71
            at new Promise (&lt;anonymous&gt;)
            at __awaiter (C:\Users\user\Documents\workspace-vs-code\protractor-
  poc\e2e\app.servicecatalogsearch.ts:3:12)
            at UserContext.&lt;anonymous&gt; (C:\Users\user\Documents\workspace-vs-co
  de\protractor-poc\e2e\app.servicecatalogsearch.ts:51:16)
        From: Task: Run it("should login") in control flow
        From asynchronous test:
        Error
            at Suite.&lt;anonymous&gt; (C:\Users\user\Documents\workspace-vs-code\pro
  tractor-poc\e2e\app.servicecatalogsearch.ts:15:5)
            at Object.&lt;anonymous&gt; (C:\Users\user\Documents\workspace-vs-code\pr
  otractor-poc\e2e\app.servicecatalogsearch.ts:3:1)
            at Module._compile (internal/modules/cjs/loader.js:689:30)
            at Module.m._compile (C:\Users\user\Documents\workspace-vs-code\pro
  tractor-poc\node_modules\ts-node\src\index.ts:422:23)
            at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
            at Object.require.extensions.(anonymous function) [as .ts] (C:\Users\A
  527629\Documents\workspace-vs-code\protractor-poc\node_modules\ts-node\src\index
  .ts:425:12)
  
  **************************************************
  *                    Failures                    *
  **************************************************
  
  1) service catalog search should login
    - Failed: script timeout: result was not received in 20 seconds
      (Session info: chrome=71.0.3578.98)
      (Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f7
  4387),platform=Windows NT 6.1.7601 SP1 x86_64)
  
  Executed 1 of 1 spec (1 FAILED) in 24 secs.
  [18:25:39] I/launcher - 0 instance(s) of WebDriver still running
  [18:25:39] I/launcher - chrome #01 failed 1 test(s)
  [18:25:39] I/launcher - overall: 1 failed spec(s)
  [18:25:39] E/launcher - Process exited with error code 1
  </code></pre>
  
  <p>And my test script is - </p>
  
  <pre><code>import { browser, element, by, until, ExpectedConditions, By } from 'protractor';
  
  describe('service catalog search', function() {
  
      it('should login', function() {
        browser.get('http://localhost:4200');
        element(by.id('password')).sendKeys('abc');
      });
    });
  </code></pre>
  
  <p>Now the problem is while sending keys. If I remove sendkeys, then it passes but don't know if it locates it properly. </p>
  
  <p>Following is the html - </p>
  
  <p><a href="https://i.stack.imgur.com/ntuzG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ntuzG.jpg" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/agAOb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/agAOb.jpg" alt="enter image description here"></a></p>