4
element(by.id('username')).sendKeys('deepu');

this throws the following error in headless mode,

Failed: No element found using locator: By(css selector, *[id="username"])

this is running fine in normal mode.

My package.json

 "dependencies": {
    "jasmine": "2.4.1",
    "typescript": "^2.1.6"
  },
  "devDependencies": {
    "@types/jasmine": "2.5.51",
    "@types/jasminewd2": "^2.0.0",
    "chromedriver": "^2.34.1",
    "protractor": "^5.2.2",
    "protractor-jasmine2-html-reporter": "0.0.7",
    "selenium-server-standalone-jar": "^3.8.1",
    "ts-node": "^3.0.2"
  }

Chrome version 63.0.3239.132 (Official Build) (64-bit)

Thanks in advance, Deepu.

UPDATE

The actual problem was in ignoring certificate errors in the headless Chrome.

I was able to run the tests fine, bypassing the untrusted certificate warning from browser, with Protractor and Firefox Quantum(57.0.4, 64-bit) headless, but had to run a standalone selenium, couldn't find anything similar to chromedriver

  framework: 'jasmine',
  capabilities: {
    browserName: 'firefox',
    acceptInsecureCerts: true,
    'moz:firefoxOptions': {
       args: [ "--headless" ]
     }
  },
  specs: [ './specs/login.spec.js' ],
  seleniumAddress: 'http://localhost:4444/wd/hub',
deepugn
  • 121
  • 1
  • 2
  • 11
  • Did you try add a long sleep before sendKeys()? But from my understanding headless mode should load page fast then normal mode, anyway you can give a try sleep. – yong Jan 16 '18 at 03:29
  • That was not the poblem, https://stackoverflow.com/questions/45510973/headless-chrome-ignore-certificate-errors This is my actual issue. – deepugn Jan 16 '18 at 09:15
  • thanks for looking into this @yong – deepugn Jan 17 '18 at 07:01
  • 1
    The actual problem was in ignoring certificate errors in the headless Chrome. Certain security related options like '--ignore-certificate-errors'are silently ignored in headless mode. See more details here, https://bugs.chromium.org/p/chromium/issues/detail?id=721739 Best Regards, Deepu. – deepugn Jan 17 '18 at 07:12
  • ``` acceptInsecureCerts: true, acceptSslCerts: true, ``` – FelikZ Dec 06 '18 at 14:33
  • "acceptInsecureCerts: true" was the answer in my case as well, not sure if it's worth updating the answer for this to reflect that since failure to find an element on the page is such a red herring for these tests. – Skeeterdrums Jan 08 '20 at 18:29

0 Answers0