Using multi capabilities is throwing error - protractor

I want to run my tests on multiple browsers and I am using the multi capabilities option to run my protractor tests in browser-stack.
Here is my protractor config file I am using
exports.config = {
specs: [
'./src/**/*.e2e-spec.ts'
],
commonCapabilities: {
browserstackUser: browserstackCredentials.user,
browserstackKey: browserstackCredentials.key,
'browserstack.debug': true,
'browserstack.local': true
},
multiCapabilities: [{
browserName: 'chrome',
os: 'Windows',
os_version: '10'
}, {
os: 'OS X',
os_version: 'High Sierra',
browserName: 'Safari'
}],
SELENIUM_PROMISE_MANAGER: false,
directConnect: false,
connectionRetryCount: 3,
connectionRetryTimeout: 90000,
framework: 'jasmine'
}
I get the below error when I run tests with these config. Below is the error I get :
[chrome #01-0] [13:46:12] E/local - Error code: 135
[chrome #01-0] [13:46:12] E/local - Error message: No update-config.json found. Run 'webdriver-manager update' to download binaries.
[chrome #01-0] [13:46:12] E/local - Error: No update-config.json found. Run 'webdriver-manager update' to download binaries.
[chrome #01-0] at Local.addDefaultBinaryLocs_ (/home/travis/build/xxx/xxx/node_modules/protractor/built/driverProviders/local.js:39:23)
[chrome #01-0] at Local.setupDriverEnv (/home/travis/build/xxx/xxx/node_modules/protractor/built/driver.
Appreciate your help.
Thanks

Looking at the error, The problem is with the file update-config.json
The behavior of protractor is to first locate the update-config.json file which contains the information of chrome/firefox driver. If the same file is not located then Protractor throw the same error as you mentioned.
Fix - Go to the path node_modules\protractor\node_modules\webdriver-manager\bin which contains webdriver-manager file.
use >> node webdriver-manager update
This command will create selenium folder under the path " your project directory\node_modules\protractor\node_modules\webdriver-manager.
Once selenium folder is created then it will have version of chrome/gecko drivers and update-config.json file.

Related

Commands not recognised in GitHub Action Mocha tests

My unit tests pass when run locally. When executed by a GitHub Action when a branch is committed, this action
on:
push:
branches:
- '*' # matches every branch that doesn't contain a '/'
- '*/*' # matches every branch containing a single '/'
- '**' # matches every branch
- '!master' # excludes master
workflow_dispatch:
inputs:
build:
description: Unit tests
type: boolean
required: true
default: "true"
jobs:
build:
strategy:
matrix:
os: [windows-latest]
# os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Install Node.js
uses: actions/setup-node#v1
with:
node-version: 16.x
- run: npm install
- run: npm i gulp gulp-cli -g
if: runner.os == 'MacOS'
- run: gulp
- run: xvfb-run -a npm test
if: runner.os == 'Linux'
- run: npm test
if: runner.os != 'Linux'
basically runs npm test.
When I do that locally, it works fine:
npm test
> vscode-print#0.9.25 test
> node ./out/test/runTest.js
Debugger listening on ws://127.0.0.1:63067/252bd7f9-c748-45b4-b9e6-8ba21e9fc909
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Found existing install in C:\Users\Peter\source\vsc-print\.vscode-test\vscode-win32-x64-archive-1.68.1. Skipping download
[16792:0704/000228.095:ERROR:node_bindings.cc(286)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[16792:0704/000228.095:ERROR:node_bindings.cc(286)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[main 2022-07-03T14:02:28.455Z] update#ctor - updates are disabled by the environment
[main 2022-07-03T14:02:29.679Z] Starting extension host with pid 32 (fork() took 15 ms).
Loading development extension at c:\Users\Peter\source\vsc-print
Decryption failed
Print Extension Test Suite
✔ Check platform browser launch command on win32 (200ms)
✔ Check platform alternate browser launch command on win32 (112ms)
✔ Print active editor (304ms)
Could not find the language 'jsonc', did you forget to load/include a language module?
✔ Print folder (812ms)
4 passing (2s)
[main 2022-07-03T14:02:32.887Z] Extension host with pid 32 exited with code: 0, signal: null.
Exit code: 0
Done
Waiting for the debugger to disconnect...
When the Action runs it, this is the output.
Downloaded VS Code into D:\a\vsc-print\vsc-print\.vscode-test\vscode-win32-x64-archive-1.68.1
[main 2022-07-03T13:06:32.496Z] update#ctor - updates are disabled by the environment
workbench#open()
[main 2022-07-03T13:06:37.868Z] Calling fork to start extension host...
[main 2022-07-03T13:06:37.879Z] Starting extension host with pid 776 (fork() took 11 ms).
IExtensionHostStarter.start() took 42 ms.
Loading development extension at d:\a\vsc-print\vsc-print
Print Extension Test Suite
1) Check platform browser launch command on win32
Error: 4 tests failed.
2) Check platform alternate browser launch command on win32
3) Print active editor
at d:\a\vsc-print\vsc-print\out\test\suite\index.js:25:27
4) Print folder
at done (d:\a\vsc-print\vsc-print\node_modules\mocha\lib\mocha.js:1009:7)
0 passing (518ms)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
4 failing
1) Print Extension Test Suite
Check platform browser launch command on win32:
Error: command 'extension.test.browserLaunchCommand' not found
at v._tryExecuteCommand (vscode-file://vscode-app/d:/a/vsc-print/vsc-print/.vscode-test/vscode-win32-x64-archive-1.68.1/resources/app/out/vs/workbench/workbench.desktop.main.js:1706:3532)
at v.executeCommand (vscode-file://vscode-app/d:/a/vsc-print/vsc-print/.vscode-test/vscode-win32-x64-archive-1.68.1/resources/app/out/vs/workbench/workbench.desktop.main.js:1706:3414)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
2) Print Extension Test Suite
Check platform alternate browser launch command on win32:
Error: command 'extension.test.browserLaunchCommand' not found
at v._tryExecuteCommand (vscode-file://vscode-app/d:/a/vsc-print/vsc-print/.vscode-test/vscode-win32-x64-archive-1.68.1/resources/app/out/vs/workbench/workbench.desktop.main.js:1706:3532)
at v.executeCommand (vscode-file://vscode-app/d:/a/vsc-print/vsc-print/.vscode-test/vscode-win32-x64-archive-1.68.1/resources/app/out/vs/workbench/workbench.desktop.main.js:1706:3414)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
3) Print Extension Test Suite
Print active editor:
Error: command 'extension.test.flags' not found
at v._tryExecuteCommand (vscode-file://vscode-app/d:/a/vsc-print/vsc-print/.vscode-test/vscode-win32-x64-archive-1.68.1/resources/app/out/vs/workbench/workbench.desktop.main.js:1706:3532)
at v.executeCommand (vscode-file://vscode-app/d:/a/vsc-print/vsc-print/.vscode-test/vscode-win32-x64-archive-1.68.1/resources/app/out/vs/workbench/workbench.desktop.main.js:1706:3414)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
4) Print Extension Test Suite
Print folder:
Error: command 'extension.test.flags' not found
at v._tryExecuteCommand (vscode-file://vscode-app/d:/a/vsc-print/vsc-print/.vscode-test/vscode-win32-x64-archive-1.68.1/resources/app/out/vs/workbench/workbench.desktop.main.js:1706:3532)
at v.executeCommand (vscode-file://vscode-app/d:/a/vsc-print/vsc-print/.vscode-test/vscode-win32-x64-archive-1.68.1/resources/app/out/vs/workbench/workbench.desktop.main.js:1706:3414)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
[main 2022-07-03T13:06:41.294Z] Waiting for extension host with pid 776 to exit.
[main 2022-07-03T13:06:41.330Z] Extension host with pid 776 exited with code: 1, signal: null.
Exit code: 1
Failed
Failed to run tests
Error: Process completed with exit code 1.
The unrecognised commands are registered near the start of the extension's activation event.
export function activate(context: vscode.ExtensionContext) {
let ecmPrint = vscode.workspace.getConfiguration("print", null).editorContextMenuItemPosition,
etmButton = vscode.workspace.getConfiguration("print", null).editorTitleMenuButton,
disposable: vscode.Disposable;
vscode.commands.executeCommand("setContext", "ecmPrint", ecmPrint);
vscode.commands.executeCommand("setContext", "etmButton", etmButton);
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(checkConfigurationChange));
context.subscriptions.push(vscode.commands.registerCommand("extension.print", printCommand));
context.subscriptions.push(vscode.commands.registerCommand("extension.printFolder", printFolderCommand));
context.subscriptions.push(vscode.commands.registerCommand("extension.test.flags", () => testFlags));
context.subscriptions.push(vscode.commands.registerCommand("extension.test.browserLaunchCommand", PrintSession.getLaunchBrowserCommand));
This suggests that the activation method hasn't been called. Is this something I must do explicitly?
I just noticed this up the top of extension.test.ts
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
// import * as myExtension from '../../extension';
That's not how my tests are written. They don't import the code and call it directly, they assume the extension is installed and active and they use registered commands. Some of these commands were added for no other reason than to allow fine grained unit tests.
The problem I describe in the question is due to the fact that the extension is not installed.
Discovering I can import from the extension doesn't solve all the problems. Some of my tests are strictly speaking integration tests. They need the extension to be installed and active.
To meet that requirement, gulp package rather than gulp build will also produce the VSIX. The only real trick is obtaining the VSIX name to install it in the test environment.
const vsixName = fs.readdirSync(extensionDevelopmentPath)
.filter(p => path.extname(p) === ".vsix")
.sort((a, b) => a < b ? 1 : a > b ? -1 : 0)[0];
const launchArgs = [
path.resolve(__dirname, '../../src/test/test-docs'),
"--install-extension",
vsixName
];
A hybrid approach is possible; some of the registered commands exist only for use by unit tests. These could be junked in favour of direct calls.

Getting Error protractor_1.browser.action is not a function

I am facing an error while performing actions.
Code of Specs file
it("testcase action", async()=> {
browser.waitForAngularEnabled(false);
await browser.get("https://google.com");
await browser.actions().mouseMove(element(by.css("input[name='q']"))).sendKeys("protrac").perform();
await browser.sleep(8000);
await browser.actions().sendKeys(protractor.Key.ARROW_DOWN);
await browser.action().sendKeys(protractor.Key.ENTER);
})
Code from Config File
import {Config, browser} from "protractor";
// An example configuration file
export let config: Config = {
// The address of a running selenium server.
//seleniumAddress: 'http://localhost:4444/wd/hub',
directConnect:true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
browserName: 'chrome',
'goog: chromeOptions':{
w3c: false
},
},
// Spec patterns are relative to the configuration file location passed
// to protractor (in this example conf.js).
// They may include glob patterns.
specs: ['testspec.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true, // Use colors in the command line report.
}
};
Error i am facing
> protractortypescriptcucumberframework#1.0.0 pretest C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework
> tsc
> protractortypescriptcucumberframework#1.0.0 test C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework
> protractor JSFiles/configuration.js
[12:35:49] I/launcher - Running 1 instances of WebDriver
[12:35:50] I/direct - Using ChromeDriver directly...
DevTools listening on ws://127.0.0.1:50594/devtools/browser/c5170ccf-5c5d-408d-8d10-c6eb3022c11f
Started
(node:7448) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues.
Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
F
Failures:
1) Action class testcase action
Message:
Failed: protractor_1.browser.action is not a function
Stack:
TypeError: protractor_1.browser.action is not a function
at C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\testspec.ts:110:15
at Generator.next (<anonymous>)
at fulfilled (C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\JSFiles\testspec.js:5:58)
From: Task: Run it("testcase action") in control flow
at UserContext.<anonymous> (C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\node_modules\jasminewd2\index.js:94:19)
From asynchronous test:
Error
at C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\testspec.ts:102:1
at Generator.next (<anonymous>)
at C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\JSFiles\testspec.js:8:71
at new Promise (<anonymous>)
at __awaiter (C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\JSFiles\testspec.js:4:12)
at Suite.fdescribe (C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\testspec.ts:99:36)
Ran 1 of 5 specs
1 spec, 1 failure
Finished in 13.633 seconds
[12:36:37] I/launcher - 0 instance(s) of WebDriver still running
[12:36:37] I/launcher - chrome #01 failed 1 test(s)
[12:36:37] I/launcher - overall: 1 failed spec(s)
[12:36:37] E/launcher - Process exited with error code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! protractortypescriptcucumberframework#1.0.0 test: `protractor JSFiles/configuration.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the protractortypescriptcucumberframework#1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2020-07-21T07_06_38_712Z-debug.log
PS C:\Users\Admin\Eclipse Protractor JavaScript\ProtractorTypeScriptCucumberFramework>

Protractor tests are not running in gitlab-ci after Google Chrome updated to version 75 yesterday. It worked before the update. What happened?

I am running a scheduled job in gitlab to run protractor tests on an application on Google Chrome. These tests were working along nicely until yesterday June 04, 2019 where Google updated chrome from version 74 to version 75. Now I am getting a "W/launcher - Ignoring uncaught error WebDriverError: Unable to parse new session response" issue since the update.
This is run on the gitlab ci environment. I don't use webdriver-manager, my team really needs me to use docker-compose to create a selenium grid. I don't really know where to start fixing this issue.
test:
stage: test
before_script:
- apk add py-pip
- pip install --upgrade pip
- pip install docker-compose==1.23.2
- docker login -u $DOCKERHUB_REGISTRY_USER -p $DOCKERHUB_REGISTRY_PASSWORD
- echo "//registry.npmjs.org/:_authToken=\${NPM_HAVENBUILD_AUTH_TOKEN}" > .npmrc
- npm install
- npm config set unsafe-perm true
- npm install -g protractor
- npm install -g protractor-console
- npm config set unsafe-perm falsesh
- ./node_modules/.bin/gulp
script:
- docker-compose up -d
- docker-compose scale chrome=2
- ./node_modules/.bin/protractor TestFiles/HConf.js --suite client --testname Happy_Path --env uat
This is the error I am getting:
[19:53:28] I/hosted - Using the selenium server at http://docker-dind:4444/wd/hub
[19:53:28] W/launcher - Ignoring uncaught error WebDriverError: Unable to parse new session response: {
"value": {
"sessionId": "d8b6ab9a6e301a943203e8af49aec285",
"capabilities": {
"acceptInsecureCerts": false,
"browserName": "chrome",
"browserVersion": "75.0.3770.80",
"chrome": {
"chromedriverVersion": "75.0.3770.8 (681f24ea911fe754973dda2fdc6d2a2e159dd300-refs\u002fbranch-heads\u002f3770#{#40})",
"userDataDir": "\u002ftmp\u002f.com.google.Chrome.zQzfpf"
},
"goog:chromeOptions": {
"debuggerAddress": "localhost:46326"
},
"networkConnectionEnabled": false,
"pageLoadStrategy": "normal",
"platformName": "linux",
"proxy": {
},
"setWindowRect": true,
"strictFileInteractability": false,
"timeouts": {
"implicit": 0,
"pageLoad": 300000,
"script": 30000
},
"unhandledPromptBehavior": "dismiss and notify",
"webdriver.remote.sessionid": "d8b6ab9a6e301a943203e8af49aec285"
}
}
}
[19:53:28] E/launcher - BUG: launcher exited with 1 tasks remaining
I am suppose to have the protractor tests run insead of this after it starts using the selenium server.
Does anyone know what the issue is?

Protractor error when running protractor conf.js

I am getting an error while execution command protractor conf.js
I am trying to run the sample project code available at
https://github.com/qualityshepherd/protractor_example
My error is
D:\Users\protractor_example-master
>protractor conf.js
[13:30:33] E/configParser - error code: 105
[13:30:33] E/configParser - description: failed loading configuration file conf.
js
D:\Users\xxxxxx\node_modules\protractor\built\configParser.js:130
throw new exitCodes_1.ConfigError(logger, 'failed loading configurat
ion file ' + filename);
Please suggest a solution
You have to go into the directory where you have your config file :
cd /yourPath/
Then run your file.
If you are using protractor-jasmine2-html-reporter then it should be installed locally to the folder where your project scripts and conf.js is present.
I was getting the below error
H:\protractorDemo>protractor conf.js
**Error:**
[05:20:41] E/configParser - Error code: 105
[05:20:41] E/configParser - Error message: failed loading configuration file con
f.js
[05:20:41] E/configParser - Error: Cannot find module 'protractor-jasmine2-html-
reporter'
at Function.Module._resolveFilename (module.js:325:15)
and after installing it using command
npm install protractor-jasmine2-html-reporter --save-dev
on folder 'H:\protractorDemo>' it started working fine.

Travis-CI build - PhantomJS error preventing QUnit tests from running

I have a repository with a simple js function and a QUnit test. I have attempted to integrate it with Travis-CI using a grunt task. Everything works fine locally but PhantomJS throws an error during the build process preventing my tests from running.
Build:
https://travis-ci.org/DaveKingsnorth/ciSandbox/builds/40909225
Repo:
https://github.com/DaveKingsnorth/ciSandbox
//.travis.yaml
language: node_js
node_js:
- "0.11"
before_install: npm install -g grunt-cli
install: npm install
// Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
pkg: '<json:package.json>',
qunit: {
src: ['test/**/*.html']
}
});
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.registerTask('test', ['qunit']);
grunt.registerTask('default', 'qunit');
};
Error:
Testing test/index.html
PhantomJS threw an error:ERROR
/home/travis/build/DaveKingsnorth/ciSandbox/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: 4: /home/travis/build/DaveKingsnorth/ciSandbox/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: Syntax error: Unterminated quoted string 0 [ '/home/travis/build/DaveKingsnorth/ciSandbox/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: 4: /home/travis/build/DaveKingsnorth/ciSandbox/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: Syntax error: Unterminated quoted string' ]
Warning: PhantomJS exited unexpectedly with exit code 2. Use --force to continue.
Aborted due to warnings.
The command "npm test" exited with 0.
Done. Your build exited with 0.