Angular end-to-end tests on random port - protractor

We are running angular e2e tests on a CI environment where tests are run at the same time on the same build slave (for example for different branches).
Since our recent upgrade to angular 7 (from angular 5) protractor uses the default port (4200).
CI jobs now occasionally are failing because port 4200 is in use.
I found the option to run with port 0:
ng e2e --port 0
This does seem to use a random port, but the tests fail, see below.
I tried on a clean new angular project created with angular cli, no changes.
ng e2e
works fine
How can I get the e2e tests to run without port number clashes?
Angular CLI: 7.1.0
node: v8.9.3
OS: Windows 10 Version 1607
Thanks in advance,
Rob
This output is from the failing run:
$ ng e2e --port 0
** Angular Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152/ **
Date: 2018-12-03T15:16:48.890Z
Hash: 97006afaee956149f40f
Time: 7337ms
chunk {main} main.js, main.js.map (main) 9.77 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 223 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.3 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.43 MB [initial] [rendered]
i 「wdm」: Compiled successfully.
[16:16:49] I/update - chromedriver: file exists C:\Users\rob.gansevles\tmp\noot\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.44.zip
[16:16:49] I/update - chromedriver: unzipping chromedriver_2.44.zip
[16:16:49] I/update - chromedriver: chromedriver_2.44.exe up to date
[16:16:50] I/launcher - Running 1 instances of WebDriver
[16:16:50] I/direct - Using ChromeDriver directly...
DevTools listening on ws://127.0.0.1:50805/devtools/browser/7ee01341-be32-4d52-ae53-0794c11c8864
Jasmine started
[23540:12920:1203/161652.814:ERROR:tcp_socket_win.cc(861)] connect failed: 10049
[23540:12920:1203/161652.814:ERROR:tcp_socket_win.cc(861)] connect failed: 10049
[23540:12920:1203/161652.823:ERROR:tcp_socket_win.cc(861)] connect failed: 10049
[23540:12920:1203/161652.823:ERROR:tcp_socket_win.cc(861)] connect failed: 10049
[16:17:03] E/protractor - Could not find Angular on page http://localhost:0/ : retries looking for angular exceeded
workspace-project App
× should display welcome message
- Failed: Angular could not be found on the page http://localhost:0/. If this is not an Angular application, you may need to turn off waiting for Angular.
Please see
https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load
Please see
https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load
at executeAsyncScript_.then (C:\Users\rob.gansevles\tmp\noot\node_modules\protractor\built\browser.js:720:27)
at ManagedPromise.invokeCallback_ (C:\Users\rob.gansevles\tmp\noot\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (C:\Users\rob.gansevles\tmp\noot\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\Users\rob.gansevles\tmp\noot\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\Users\rob.gansevles\tmp\noot\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at C:\Users\rob.gansevles\tmp\noot\node_modules\selenium-webdriver\lib\promise.js:668:7
at
at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: Run it("should display welcome message") in control flow
at ControlFlow.emit (C:\Users\rob.gansevles\tmp\noot\node_modules\selenium-webdriver\lib\events.js:62:21)
at ControlFlow.shutdown_ (C:\Users\rob.gansevles\tmp\noot\node_modules\selenium-webdriver\lib\promise.js:2674:10)
at shutdownTask_.MicroTask (C:\Users\rob.gansevles\tmp\noot\node_modules\selenium-webdriver\lib\promise.js:2599:53)
From asynchronous test:
Error
at Suite. (C:\Users\rob.gansevles\tmp\noot\e2e\src\app.e2e-spec.ts:10:3)
at Object. (C:\Users\rob.gansevles\tmp\noot\e2e\src\app.e2e-spec.ts:3:1)
at Module._compile (module.js:635:30)
at Module.m._compile (C:\Users\rob.gansevles\tmp\noot\node_modules\ts-node\src\index.ts:439:23)
at Module._extensions..js (module.js:646:10)
at Object.require.extensions.(anonymous function) [as .ts] (C:\Users\rob.gansevles\tmp\noot\node_modules\ts-node\src\index.ts:442:12)
Failures *
1) workspace-project App should display welcome message
- Failed: Angular could not be found on the page http://localhost:0/. If this is not an Angular application, you may need to turn off waiting for Angular.
Please see
https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load
Executed 1 of 1 spec (1 FAILED) in 10 secs.
[16:17:03] I/launcher - 0 instance(s) of WebDriver still running
[16:17:03] I/launcher - chrome #01 failed 1 test(s)
[16:17:03] I/launcher - overall: 1 failed spec(s)
[16:17:03] E/launcher - Process exited with error code 1
An unexpected error occurred: undefined
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command

Related

IE intstances is not working with protractor e2e

I have version :-
protractor 5.4.2
webdriver-manager version is 12.1.7
angular 7.2.4
Steps to run our app on IE:
run webdriver-manager update --ie
IEdriverserver.exe is 3.150.1 ,
standalone service is 3.14.59 jar
geckodriver-v0.26.0.exe
chromedriver_79.0.3945.36.zip
run webdriver-manager start --ie
open another terminal and run ng e2e
the error was:
Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
i 「wdm」: Compiled successfully.
[12:05:28] I/launcher - Running 1 instances of WebDriver
[12:05:28] I/local - Starting selenium standalone server...
[12:05:29] I/local - Selenium standalone server started at http://10.154.204.250:52076/wd/hub
[12:05:29] E/launcher - Unable to create new service: InternetExplorerDriverService
os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: driver.version: unknown
[12:05:29] E/launcher - SessionNotCreatedError: Unable to create new service: InternetExplorerDriverService
can you help me why I am receiving this error and how I can fix this?

Ionic serve doesn't work/ exits batch

I am struggling to get the ionic serve command working .
Right now whener I go into my project folder inside the cmd and run the command it gives me the following output:
Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser -
Ctrl+C to cancel
[01:44:47] watch started ...
[01:44:47] build dev started ...
[01:44:47] clean started ...
[01:44:47] clean finished in 6 ms
[01:44:47] copy started ...
[01:44:47] deeplinks started ...
[01:44:47] deeplinks finished in 21 ms
[01:44:47] transpile started ...
[01:44:50] transpile finished in 3.19 s
[01:44:50] preprocess started ...
[01:44:50] preprocess finished in less than 1 ms
[01:44:50] webpack started ...
[01:44:50] copy finished in 3.37 s
[01:44:55] webpack finished in 5.10 s
[01:44:55] sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[01:44:56] sass finished in 974 ms
[01:44:56] postprocess started ...
[01:44:56] postprocess finished in 8 ms
[01:44:56] lint started ...
[01:44:56] build dev finished in 9.44 s
[01:44:57] watch ready in 9.52 s
[01:44:57] dev server running: http://localhost:8100/
[OK] Development server running!
Local: http://localhost:8100
External: http://111.111.1.111:8100
DevApp: foo#8100 on DESKTOP-11QG111
It seems to be working fine but it doesn't stay inside the batch, instead it just exits it and therefore the server is not running. I am confused on why it doesn't work.
For the benfit of anyone stumbling onto this, the solution on Windows is to make sure that
C:\windows\system32 is in the PATH environment variable

Ionic Serve Not Serving

When I run ionic serve, it builds the app but the server isn't run. Here's the trail:
Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729
--dev-logger-port 53703 --nobrowser - Ctrl+C to cancel
[17:55:35] watch started ...
[17:55:35] build dev started ...
[17:55:36] clean started ...
[17:55:36] clean finished in 2 ms
[17:55:36] copy started ...
[17:55:36] deeplinks started ...
[17:55:37] deeplinks finished in 589 ms
[17:55:37] transpile started ...
[17:55:44] transpile finished in 7.38 s
[17:55:44] preprocess started ...
[17:55:44] copy finished in 8.56 s
[17:55:44] preprocess finished in 206 ms
[17:55:44] webpack started ...
After webpack started the cli just exits and i see the normal terminal prompt.
Trying out the npm run ionic:serve command instead results into this error:
TypeError: Cannot read property 'substr' of undefined
So far I've re-installed ionic, same result. A bit unsure how to deal with this one...
It turns out that this is caused when creating multiple component classes in one ts file. Splitting those classes each into their own file solves the problem.
Related to this https://github.com/ionic-team/ionic-app-scripts/issues/796

Protractor: setSize() failing with "WebDriverError: disconnected: unable to connect to renderer"

Starting October 18th upon upgrading to Chrome 62 my protractor suite started failing with:
WebDriverError: disconnected: unable to connect to renderer
when I called
WebDriver.manage().window().setSize(1280, 1480)
Full stack trace:
Stack Trace:
Running "protractor:default" (protractor) task
[10:48:23] I/launcher - Running 1 instances of WebDriver
[10:48:23] I/direct - Using ChromeDriver directly...
protractor startup failure: WebDriverError: disconnected: unable to connect to renderer
(Session info: chrome=62.0.3202.62)
(Driver info: chromedriver=2.32.498537 (cb2f855cbc7b82e20387eaf9a43f6b99b6105061),platform=Mac OS X 10.12.6 x86_64)
[10:48:24] E/launcher - Error: WebDriverError: disconnected: unable to connect to renderer
(Session info: chrome=62.0.3202.62)
(Driver info: chromedriver=2.32.498537 (cb2f855cbc7b82e20387eaf9a43f6b99b6105061),platform=Mac OS X 10.12.6 x86_64)
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.manage().window().setSize(1280, 1480)
at setWindowDimensions (/Users/kyle/projects/c/web/build/config/protractor-conf.js:95:43)
at onPrepare (/Users/kyle/projects/c/web/build/config/protractor-conf.js:71:12)
at Function.promise (/Users/kyle/projects/c/web/node_modules/q/q.js:682:9)
at _fulfilled (/Users/kyle/projects/c/web/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/Users/kyle/projects/c/web/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/Users/kyle/projects/c/web/node_modules/q/q.js:796:13)
at /Users/kyle/projects/c/web/node_modules/q/q.js:556:49
at runSingle (/Users/kyle/projects/c/web/node_modules/q/q.js:137:13)
at flush (/Users/kyle/projects/c/web/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
[10:48:24] E/launcher - Process exited with error code 100
Env Info:
ChromeDriver: chromedriver=2.32.498537 (cb2f855cbc7b82e20387eaf9a43f6b99b6105061), platform=Mac OS X 10.12.6 x86_64
Chrome : 62.0.3202.62
Protractor: 5.1.2 (connecting directly to chromedriver)
Node: v6.9.5
Upgrading to chromedriver 2.33 fixed my issue.
To specify a version when running webdriver-manager :
webdriver-manager update --versions.chrome 2.33

Karma error: TypeError: 'undefined' is not an object

while running Karma test running I am seeing all these weird errors. Any ideas?
[jenkins#xcclx0194 workspace]$ karma start karma.conf.js --single-run
INFO [karma]: Karma v0.12.16 server started at http://jenkins.test.com:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Linux)]: Connected on socket 287TYh_PCxnMv4F5SzII with id 8378863
PhantomJS 1.9.7 (Linux) ERROR
TypeError: 'undefined' is not an object (evaluating 'Toolbox.Base')
at /apps/devops/jenkins/home/jobs/UIMod-Jasmine-Karma/workspace/WebContent/js/controllers/common/base.controller.js:4
PhantomJS 1.9.7 (Linux): Executed 4 of 38 ERROR (0.126 secs / 0.043 secs)
Thanks.