Can not run protractor tests with headless chrome - protractor

Some time ago google announced that headless chrome is available in newest chrome versions.
Over there we can find config for headless chrome with protractor.
When I'm trying to run my test suite with directConnect - everything works as a charm.
capabilities looks like that:
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--start-maximized']
}
},
When I change args line to:
args: ['--start-maximized', '--headless', '--disable-gpu']
and run tests, I receive an error:
E/protractor - Could not find Angular on page https://address.com/ : retries looking for angular exceeded
Unhandled rejection Error: Angular could not be found on the page https://address.com/.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
at executeAsyncScript_.then (/home/user/Projects/pef/tests/e2e/node_modules/protractor/lib/browser.ts:936:29)
at ManagedPromise.invokeCallback_ (/home/user/Projects/pef/tests/e2e/node_modules/selenium-webdriver/lib/promise.js:1366:14)
at TaskQueue.execute_ (/home/user/Projects/pef/tests/e2e/node_modules/selenium-webdriver/lib/promise.js:2970:14)
at TaskQueue.executeNext_ (/home/user/Projects/pef/tests/e2e/node_modules/selenium-webdriver/lib/promise.js:2953:27)
at asyncRun (/home/user/Projects/pef/tests/e2e/node_modules/selenium-webdriver/lib/promise.js:2813:27)
at /home/user/Projects/pef/tests/e2e/node_modules/selenium-webdriver/lib/promise.js:676:7
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Have anyone faced with this issue?
node: v8.4.0
npm: 5.3.0
chrome: 60.0.3112.113
protractor: 5.1.2

Related

Protractor issue with chromedriver versions like 76.0.3809.12

Protractor issue while running the conf.js file for new chromedriver versions like 76.0.3809.68
I am trying to run the protractor tests on latest chrome version which got updated today 76.0.3809.100 but they keep failing and giving error. The versions that i have are protractor version: 5.4.2,
webdriver-version: 12.1.6,
selenium standalone version available: 3.141.59
chromedriver versions available: 2.46 [last], 76.0.3809.12
geckodriver version available: v0.24.0 [last]
I have tried updating the webdriver manager using webdriver-manager update to update the chrome driver, have also tried to reinstall the webdriver-manager and insatll a specific version of webdriver but nothing seems to be working. I also tried to install a lower version of chrome i.e 75 but everytime i try it installs the latest version instead. The tests were running fine before just after the update they stopped working.
Any help / suggestion regarding this issue would be really helpful.
This is the error being thrown:
E/launcher - session not created: Chrome version must be between 71 and 75
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17763 x86_64)
[15:08:03] E/launcher - SessionNotCreatedError: session not created: Chrome version must be between 71
and 75
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17763 x86_64)
at Object.checkLegacyResponse (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
at Function.createSession (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\chrome.js:761:15)
at Direct.getNewDriver (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\built\driverProviders\direct.js:77:33)
at Runner.createBrowser (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\built\runner.js:195:43)
at q.then.then (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\built\runner.js:339:29)
at _fulfilled (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30
at Promise.promise.promiseDispatch (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
at C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:556:49
at runSingle (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:137:13)
[15:08:03] E/launcher - Process exited with error code 199
This is my conf.js file exports.config = {
directConnect: true,
multiCapabilities: [{
browserName: 'chrome',
acceptInsecureCerts: true,
'specs': [
//e2e Specs
'./src/e2e/shared/specs/LoginTest.e2e.spec.js',
'./src/api/unified-message-api/specs/createUMTask.js',
],
chromeOptions: {
args: ['--disable-infobars', '--disable-browser-side-navigation'],
prefs: {
'profile.managed_default_content_settings.notifications': 1
}
},
}],
framework: 'jasmine2',
SELENIUM_PROMISE_MANAGER: true,
onPrepare: function () {
browser.ignoreSynchronization = true;
browser.driver.manage().timeouts().implicitlyWait(5000);
browser.driver.manage().window().setSize(1280, 1024);
//npm install jasmine-spec-reporter --save-dev
var specReporter = require('jasmine-spec-reporter').SpecReporter;
jasmine.getEnv().addReporter(new specReporter({
displayFailuresSummary: true,
displayFailuredSpec: true,
displaySuiteNumber: true,
displaySpecDuration: true
}));
var AllureReporter = require('jasmine-allure-reporter');
jasmine.getEnv().addReporter(new AllureReporter({
resultsDir: 'allure-results'
}));
jasmine.getEnv().afterEach(function (done) {
browser.takeScreenshot().then(function (png) {
allure.createAttachment('Screenshot', function () {
return new Buffer(png, 'base64')
}, 'image/png')();
done();
})
});
},
jasmineNodeOpts: {
defaultTimeInterval: 6000000
}
};
/* Version Used:
Node: 10.15.3
Protractor : 5.4.2
npm i protractor#5.4.2
*/
The solution that worked for me was navigating to ./node_modules/protractor and running npm i webdriver-manager#latest.
Then go back to the app root and run webdriver-manager update and this time it should download the v76 driver.
You need to install compatible chromedriver version which is 76.0.0. chromedriver versioning convention is now changed to track the chrome version.
I was also facing same issue, here is a workaround which I tried and it helped me:
I did a fresh install of Node, npm, Protractor - All latest versions
I did npm install -g protractor and webdriver-manager update which downloaded chromedriver_76.0.3809.12.zip and geckodriver_v0.24.0
Also I am using few npm modules in my test which I install locally by npm install command under ~\<Project Folder>\Test\npm_modules
I replaced content of selenium folder from C:\Users\<username>\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\selenium\ to ~\<Project Folder>\Test\npm_modules\Protractor\node_modules\webdriver-manager\selenium\
and this fixed the above mentioned error.

Protractor Process exited with error code 100

I'm trying to setup protractor on different computer. It is using the same files with my other computer (cannot be used because hdisc corrupted).
It run fine on my other computer but I am getting error "Process exited with error code 100" when I tried to run protractor on this one.
I've tried to delete the node modules, clean cache and perform npm install again to install the dependencies. It helps my earlier issue (cannot run webdriver) but is now causing me this one.
[14:44:09] I/launcher - Running 1 instances of WebDriver
[14:44:09] I/local - Starting selenium standalone server...
[14:44:11] E/launcher - Error: Error: Server terminated early with status 1
at earlyTermination.catch.e (C:\Users\PMO\Documents\DG\Jasmine\node_modules\selenium-webdriver\remote\index.js:252:52)
at process._tickCallback (internal/process/next_tick.js:68:7)
[14:44:11] E/launcher - Process exited with error code 100
npm ERR! code ELIFECYCLE
npm ERR! errno 100
npm ERR! ProtractorTutorial# protractor: `protractor conf.js`
npm ERR! Exit status 100
npm ERR!
npm ERR! Failed at the protractor# protractor script.
My current chrome version is: 74.0.3729.131
Webdriver version: chromedriver_74.0.3729.6.exe
OS: Windows 10.
Please advise me on how to fix this issue. Or is there any specific version of chrome and webdriver that can work?
use directConnect=true in your config. if you are already using that, The problem is with the webdriver.
Try running below commands from your project location
webdriver-manager clean
node node_modules/protractor/bin/webdriver-manager update --standalone --versions.standalone=3.8.0
I encountered a similar issue yesterday and inspired by Madhan's solution I worked it out.
I'm learning angularJS thru the official tutorial. I found protractor is actually a standalone tool (I'm a newbie in front-end development), which means it can be run separately.
So following the official setup guide, I run
protractor e2e-tests/protractor.conf.js
and found below feedback:
E/launcher - SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 77
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'xxx', ip: 'xxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '11.0.2'
Driver info: driver.version: unknown
remote stacktrace: 0 chromedriver_77.0.3865.40 0x00000001078b7f09 chromedriver_77.0.3865.40 + 3694345
And my chrome version was 76 in the moment.
So after I upgraded chrome to 77, it worked.
Tips:
if use directConnect=true in your config still doesn't work, try to run in standalone mode, which can provide you more useful feedback.
For me, the issue was a space after Scenario in the feature file
Wrong Scenario :
Corrected to Scenario: and the feature started executing
Cant see this answer above, so this might help someone
Your problem might be that you need to run your tests without sudo!
Sometimes if you get an EACCESS error, you can then change directory permissions so that you can run it without sudo.
My issue here was an outdated version of webdriver-manager. This fix only partially fixes the issue because it does not update the npm package. To completely fix this you need to ensure your package.json is configured with the correct webdriver-manager version (npm install webdriver-manager#latest --save-dev). Then you'll need to run:
npm install
node ./node_modules/protractor/bin/webdriver-manager clean
node ./node_modules/protractor/bin/webdriver-manager update
You may also need to run a npm dedupe to ensure all items are using the new package
In my case I had to run update + start
node node_modules/protractor/bin/webdriver-manager update --standalone --versions.standalone=3.8.0
node node_modules/protractor/bin/webdriver-manager start --standalone --versions.standalone=3.8.0
thank you 🤘🏻
For me it was a missing tsconfig.json file in my e2e folder. If you don't have one in your e2e folder, simply create one and put this code into it. Then run ng e2e again.
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}
I'm using:
Angular CLI: 9.0.7
Node: 14.16.0
Chrome: 89.0.4389.82
chromedriver_89.0.4389.23

Getting DnsPrefetchingEnabled issue on protractor while it works fine via Java

Chrome version: 57.0.2987.110 Chrome web driver: 2.28 Protractor:
5.1.2 Node: 6.9.1
When I run my scripts via protractor I see this error:
ERROR:configuration_policy_handler_list.cc(92)] Unknown policy:
DnsPrefetchingEnabled ERROR:configuration_policy_handler_list.cc(92)]
Unknown policy: PasswordManagerAllowShowPasswords
When I run the similar test case via Java selenium it works fine & does not return error like above.
So I am assuming local group policy is not an issue here but protractor is dealing with web driver in a different way than Java.
I have tried these Chrome options:
'chromeOptions': {
'args': ['incognito','--no-sandbox','--disable-gpu',
'--disable-web-security','--DNS-prefetch-disable']
}
'chromeOptions': {'args': ['lang=en-GB', 'enable-precise-memory-info' , 'js-flags=--expose-gc', 'no-sandbox']}
I'm using this and works perfect for me.

How to use Protractor with chromeless

Is protractor compatible with chromeless? If so, how can I configure it?
I didn't find any configuration method online or specific documentation to implement chromeless at protractor configuration.
I'm using protractor 3.1.1
Chrome headless mode is available on Mac and Linux in Chrome 59. Windows support is in Chrome 60.
capabilities: {
'browserName': process.env.PROTRACTOR_BROWSER || 'chrome',
// Using headless Chrome
chromeOptions: {
args: ['--headless', '--disable-gpu', '--start-maximized']
}
}

can't run protractor tests on macOS Sierra, Safari 10.0.2

I'm getting a UnsupportedOperationError: Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800' when i run my protractor 5.0.0 tests on safari.
I have a webdriver 2.48.0 extension enabled in safari.
conf file:
capabilities: {
name: 'Safari',
browserName: 'safari',
logName: 'Safari',
shardTestFiles: true,
maxInstances: 2
}
seleniumAddress: 'http://localhost:4444/wd/hub'
I'm starting the server manually by
./node_modules/.bin/webdriver-manager start
and running the spec in a different terminal
Am I supposed to run a specific version of selenium server. Any help would be appreciated.
macOS Sierra with Safari 10.0.2 needs the new Safari Driver. The Safari webdriver 2.48.0 extenson is for Safari 9 and lower.
There are some issues with the new Safari driver, see also here and search Google ;-).
Keep in mind that for example the Wait For Angular doesn't work, to avoid that use browser.ignoreSynchronization = true;