Protractor fails to find web-manager - npm

I have protractor installed in project folder + web-manager (installed the same way).
The web-manager is started:
$npm-run webdriver-manager status
webdriver-manager: using global installed version 12.0.6
- selenium standalone version available: 3.8.1 [last]
- chromedriver version available: 2.35 [last]
- geckodriver version available: v0.19.1 [last]
- IEDriverServer is not present
However, when I run protractor
$ npm-run protractor conf.js
[15:22:12] I/launcher - Running 1 instances of WebDriver
[15:22:12] E/local - Error code: 135
[15:22:12] E/local - Error message: No update-config.json found. Run 'webdriver-manager update' to download binaries.
[15:22:12] E/local - Error: No update-config.json found. Run 'webdriver-manager update' to download binaries.
Here is my conf.js for protractor
exports.config = {
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome',
},
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['tests/common/*.js'],
};
How do I fix the config/run protrator?

you need to run npm-run webdriver-manager update to install webdriver binary and selenium-standalon-server.jar if you never execute it, otherwise the command will update existed stuff.
After that, find update-config.json in node_modules\protractor\node_modules\webdriver-manager\selenium.
Its content should be like this:
{
"chrome": {
"last": "xxx\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\chromedriver_2.35.exe",
"all": ["xxx\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\chromedriver_2.35.exe"]
},
"standalone": {
"last": "xxx\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\selenium-server-standalone-3.9.0.jar",
"all": ["xxx\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\selenium-server-standalone-3.9.0.jar"]
},
"gecko": {
"last": "xxx\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\geckodriver-v0.19.1.exe",
"all": ["xxx\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\geckodriver-v0.19.1.exe"]
}
}
Then execute node_modules\.bin\webdriver-manager start to see will success or fail.
FYI, you need JDK 8 installed to start webdriver-manager.

Finally, found a solution using gulp.
The config below allows to run webmanager-update, webmanager-start and proptractor on by one.
gulp.js
var gulp = require('gulp'),
shell = require('gulp-shell'),
connect = require('gulp-connect'); // Webserver
protractor = require('gulp-protractor').protractor,
webdriver_standalone = require('gulp-protractor').webdriver_standalone,
webdriver_update = require('gulp-protractor').webdriver_update;
gulp.task('webdriver_update', webdriver_update);
gulp.task('webdriver_standalone', webdriver_standalone);
gulp.task('e2e', ['webdriver_update'], function() {
gulp.src(["tests/protractor/*.js"])
.pipe(protractor({
configFile: "protractor.conf.js",
args: [
//'--baseUrl', 'http://127.0.0.1:8000',
// '--suite', 'login',
// '--params.environment', 'test'
]
}))
.on('error', function(e) { throw e })
});
protractor.conf.js
exports.config = {
seleniumServerJar: './node_modules/webdriver-manager/selenium/selenium-server-standalone-3.9.0.jar',
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome',
},
};
(using URL for selenium server is impotant)
Launch command:
gulp e2e

Related

why It show me This version of ChromeDriver only supports Chrome version 104?

when I use wdio for e2e tests, I got an exception.But my chromedriver is 106.0.1.
[0-1] 2022-10-24T10:58:18.928Z ERROR webdriver: Request failed with status 500 due to session not created: session not created: This version of ChromeDriver only supports Chrome version 104
[0-1] Current browser version is 106.0.5249.119 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
but when I check chromedriver:
chromedriver -v
ChromeDriver 106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249#{#569})
I has been tried all those methods:
SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81.
But I still got same exception.please help me.
My configureation:
module.exports.config = {
runner: "local",
path: "/wd/hub",
specs: ["./test/specs/*.js"],
maxInstances: 1,
capabilities: [
{
pageLoadStrategy: "none",
maxInstances: 1,
//
browserName: "chrome",
"goog:chromeOptions": {
excludeSwitches: ["enable-automation"],
},
},
],
logLevel: "warn",
bail: 0,
baseUrl: "http://localhost:3333",
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: ["chromedriver"],
framework: "mocha",
reporters: ["spec"],
}
I resolve this question by configure path.
services: [
[
"chromedriver",
{
chromedriverCustomPath: "/usr/local/bin/chromedriver",
},
],
],
I solved this problem by configuring the path. But I don't think this is a good method, because it means that any participant who uses this testing function needs to set the chromedriver in this path.
In fact, another project with the same npm version and my other configuration can run normally without configuring the path. This is really strange! This shows that my local chromedriver has no problems and can run directly.

protractor/selenium started ignoring the chrome options (chromeOptions) in protractor.conf.js

I just rebuilt our development environment. This forced the latest version of chrome and suddenly the protractor based tests stopped working. After some research, I tracked this down to the fact that our chrome options in the protractor configuration file are now ignored.
Here is the configuration that used to work fine before:
exports.config = {
...
multiCapabilities : [
{
browserName: "chrome",
chromeOptions: {
args: [
"--disable-gpu",
"--headless",
'--no-sandbox',
"--incognito"
]
}
},
},
],
...
};
Before After
protractor 6.0.0 6.0.0
selenium 4.0.0-alpha-1 4.0.0-alpha-1
chrome 74.0.3729.157 76.0.3809.100
chromedriver 74.0.3729.6 76.0.3809.68
In recent versions of selenium you have to specify the chrome options as goog:chromeOptions. So just change the chromeOptions line above to the following:
...
"goog:chromeOptions": {
...
and you are back in business.
"chromeOptions": {}
its still usable in most cases, but does not support new arguments provided by chrome
suggested to use
"goog:chromeOptions": {}
Ref to doc: http://chromedriver.chromium.org/capabilities
Same rule for firefox
"moz:firefoxOptions": {}
Ref to doc: https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions

How to run successfully Protractor e2e test in Cloud Builders?

I'm setting up CI for our project that is in Angular. We are using Google Cloud Platform's Cloud Builder for CI. Everything is going smoothly, we can setup the environment, install packages via npm, build the project using angular-cli and deploy. But the problem is that our test cases (e2e) in Protractor keeps getting an error. What are we missing here?
This is for the Continuous Integration using Google Cloud Builders, we are running the protractor in headless mode, and using the puppeteer's chromium as the chrome's binary path
This is my protractor.conf.js
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath()
exports.config = {
allScriptsTimeout: 1000000,
specs: [
'./e2e/*.e2e-spec.ts',
'../e2e/*.e2e-spec.ts'
],
capabilities: {
// browserName: 'chrome',
browserName: 'chrome',
chromeOptions: {
binary: process.env.CHROME_BIN,
args: ['--headless', '--disable-gpu', '--no-sandbox', '--disable-extensions', '--disable-dev-shm-usage', '--disable-setuid-sandbox']
}
},
// seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
// ignoreUncaughtExceptions: true,
directConnect: true,
},
};
This is the error we are getting in cloud builders
[11:24:12] E/launcher - unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-1033-gcp x86_64)
[11:24:12] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Cannot run e2e tests with protractor: cannot resolve path?

I can’t seem to run my e2e tests with protractor. Before I begin here is some background info:
Node: 7.7.4
NPM: 4.1.2.
Angular: 4.1.0
Protractor: 5.1.2
After I ran npm install protractor, I installed and updated web driver and got an update for IE. After I wrote my first test—a simple test to grab the text of the h1 tag on my login page—I attempted to run protractor and got an error: Error: Cannot find module ‘ts-node’ so I went and installed that. Now when I rerun protractor I get a mysterious error I cannot resolve: the specified path does not exist: e2e/tsconfig.e2e.json. What does this mean? My protractor conf.js file looks like this:
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [ //path of specs is relative to location of protractor.conf.js file.
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
//'browserName': 'chrome' ---default
'browserName': 'internet explorer',
'platform': 'ANY',
'version': '11'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare() {
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
I tried fooling around with the path under the project parameter, but no luck with that resolving the issue. And my project structure is set up likes this:
Any suggestions? Should I post this as an issue on github? To ts-node? Or protractor? Any suggestions would be appreciated. Please let me know if you need additional context too.
It means it's trying to find tsconfig.e2e.json (the typescript config file for your 'e2e' project) and can't. This part of the config shows the path it's looking for:
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
But it's clear from your directory structure that it isn't there. Given the path to your spec files, I would imagine the line should read:
project: './e2e/tsconfig.e2e.json'
Looking at your project structure though, it could well be:
project: './app/e2e/tsconfig.e2e.json'
In which case, the path to your spec files will probably need changing to match.

How to setup Selenium grid remotely in protractor

I have my conf.js file which runs fine locally. But now as per my requirement I need to run it in a bamboo task. Since my code is going to run on server there is a remote selenium webdriver that i need to add to the conf.js.
Can you please help me out how it is done? My conf.js looks like this :
exports.config = {
params: {
url: "URL",
testroadname:"Testing123",
sleeptime:1000
},
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['mapfeedback.js'],
// Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
You have to remove directConnect = true and just give the seleniumAddress in your config or setup an environment.js file- you can simply add your remote selenium's address and fire up your protractor tests, following will be your environment.js-
// Common configuration files with defaults plus overrides from environment vars
var webServerDefaultPort = 8081;
module.exports = {
// The address of a running selenium server.You can add your remote address here
seleniumAddress:
(process.env.SELENIUM_URL || 'http://localhost:4444/wd/hub'),
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName':
(process.env.TEST_BROWSER_NAME || 'chrome'),
'version':
(process.env.TEST_BROWSER_VERSION || 'ANY')
},
// Default http port to host the web server
webServerDefaultPort: webServerDefaultPort,
// Protractor interactive tests
interactiveTestPort: 6969,
// A base URL for your application under test.
baseUrl:
'http://' + (process.env.HTTP_HOST || 'localhost') +
':' + (process.env.HTTP_PORT || webServerDefaultPort)
};
your config file will look like -
var env = require('./environment.js');
exports.config = {
params: {
url: "URL",
testroadname:"Testing123",
sleeptime:1000
},
seleniumAddress: env.seleniumAddress,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['mapfeedback.js'],
// Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
To setup selenium-grid remotely for Protractor :-
start hub with command :-
java -jar selenium-server-standalone-3.3.1.jar -role hub -port 4444
Now start your remote node with command where you want execute remote test cases :-
java -jar selenium-server-standalone-3.3.1.jar -role webdriver -hub http://HubDomain-IP:4444/grid/register -port 5556 -browser browserName=internet explorer,maxInstances=1,platform=WINDOWS,applicationName=remoteNode -Dwebdriver.ie.driver=path to IEDriverServer.exe
Once your selenium-grid setup is done and node get connected with Hub, then take config file with configuratiion set as this conf.js file:-
exports.config = {
//The address of your running selenium Hub server.
seleniumAddress: 'http://HubDomain-IP:4444/wd/hub',
//Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'internet explorer',
// add node-name as applicationName where you have started node and wanted to remotely execute test cases
'applicationName': 'remoteNode'
},
//Specify the name of the specs files.
specs: ['grid_spec.js'],
//Options to be passed to Jasmine-node.
jasmineNodeOpts: {
onComplete: null,
isVerbose: false,
showColors: true,
includeStackTrace: true
}
};
With above mentioned configuration and setup commands you could run selenium-grid setup for Protractor.Thanks !