Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor with Headless Chrome does not work on AWS CodeBuild but does work locally

I have a webpage that requires Google Authentication before proceeding to an angular web page, and I've built some very basic end-to-end tests, which work like a charm in Linux with Chrome Headless:

  1. Finds the username field
  2. Inputs the proper email address, and clicks next
  3. Enters the password to log in
  4. Once it passes Google Authentication, it verifies the title of the page is "Expense"

Here's the final message I get in the Terminal: Executed 3 of 3 specs SUCCESS in 46 secs.

In AWS CodeBuild, though, we are ALSO using a Linux (Ubuntu) container, and that fails every single time.
Here's the first error: ... Jasmine started

  1. Finding the username field
  2. Inputting the proper test email address

0 h1 tags identified Expense App E2E Initial Test Suite index page for Expense should work just fine

  • [31m✗ should sign in correctly with test user·[39m
  • [31m- ·[39m·[31mFailed: No element found using locator: By(css selector, *[id="identifierId"])
  • [39m at elementArrayFinder.getWebElements.then (/codebuild/output/src609592849/src/node_modules/protractor/built/element.js:814:27)

Here's the setup info in protractor.conf.js:

capabilities: {
'browserName': 'chrome',
chromeOptions: {
    args: ["--headless", "--disable-dev-shm-usage", "--no-sandbox", "--disable-gpu", "--window-size=1280x960"]
    }
},
directConnect: true,  // Test scripts communicate directly with Chrome Driver, so they start up and run faster

From the package.json, I'm using: "e2e": "ng e2e --port 4200",

From the buildspec-test.yml, I have the following post_build command: - npm run e2e

Why does Chrome Headless find my webpage on http://localhost:4200 without issue on my local Linux issue, but fails to find it in AWS CodeBuild when they BOTH run Ubuntu Linux? Local version: Ubuntu 18.04.1 LTS AWS CodeBuild version: Ubuntu Ubuntu 14.04.5 LTS (Trusty)

Please let me know, and thanks in advance!

Sincerely,

PW

like image 713
Patrick Walters Avatar asked Nov 06 '22 23:11

Patrick Walters


1 Answers

Yes, I do have this answer. A friend and coworker (Thanks, Bill T.) was able to create a Docker container with Ubuntu 18.04LTS, and let me run it within AWS CodeBuild, where it worked. This proved the issue: You cannot use headless chrome with the older Ubuntu 14.04.5 LTS. Start with nothing older than Ubuntu 18.04 LTS.

like image 76
Patrick Walters Avatar answered Nov 14 '22 22:11

Patrick Walters