Webdriver IO - Error: Command "printPage" is not yet implemented - selenium-chromedriver

Unable to use printPage and I also get the same error for savePDF
await browser.url('https://stackoverflow.com/')
await browser.printPage()
Results in:
Error: Command "printPage" is not yet implemented
at Browser.retries (D:\Code\Repositories\auto-browse\node_modules\devtools\build\devtoolsdriver.js:90:34)
at Browser.wrapCommandFn (D:\Code\Repositories\auto-browse\node_modules\#wdio\utils\build\shim.js:131:38)
at Browser.<anonymous> (D:\Code\Repositories\auto-browse\node_modules\#wdio\utils\build\shim.js:270:24)
at makePuzzle (D:\Code\Repositories\auto-browse\index.js:153:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async D:\Code\Repositories\auto-browse\index.js:183:5
package.json
"devDependencies": {
"#babel/core": "^7.15.8",
"#babel/preset-env": "^7.15.8",
"#babel/register": "^7.15.3",
"#wdio/cli": "^7.16.2",
"#wdio/local-runner": "^7.16.2",
"#wdio/mocha-framework": "^7.16.1",
"#wdio/spec-reporter": "^7.16.1",
"chromedriver": "^95.0.0",
"wdio-chromedriver-service": "^7.2.2"
},
"dependencies": {
"#wdio/selenium-standalone-service": "^7.16.3",
"cors": "^2.8.5",
"express": "^4.17.1",
"xlsx": "^0.17.3"
}
Any ideas? I thought it might have been because Chrome is on version 95xxxx and chromedriver was on 94xxx but I sill get the same issue after deleting Node Modules and reinstalling with the above dependencies.

Related

Error in WDIO Chai/ Cucumber testsuite after updating chromedriver: #wdio/runner: TypeError: hooks.map is not a function at Obj.executeHooksWithArgs

I'm working on Wdio-Chai-Cucumber based e2e-testsuite that ran fine untill I had to update the chromedriver.
This is my stack:
"devDependencies": {
"#types/chai": "^4.2.13",
"#types/cucumber": "^6.0.1",
"#types/node": "^14.11.8",
"#types/webdriverio": "^5.0.0",
"#wdio/cli": "6.6.2",
"#wdio/cucumber-framework": "^6.10.6",
"#wdio/local-runner": "6.6.2",
"#wdio/spec-reporter": "6.8.1",
"#wdio/sync": "6.10.4",
"chai": "^4.2.0",
"chromedriver": "90.0.1",
"cucumber": "^7.0.0-rc.0",
"cucumber-html-reporter": "5.2.0",
"del-cli": "^3.0.1",
"eslint": "^7.10.0",
"wdio-chromedriver-service": "^7.1.0",
"wdio-cucumber-parallel-execution": "^3.6.14",
"wdio-cucumberjs-json-reporter": "2.0.2",
"wdio-docker-service": "^3.1.2"
},
"dependencies": {
"ts-node": "^9.0.0",
"typescript": "^4.0.3"
},
After updating the projects chromedriver from v90 to v98 I get the following error when I run "yarn run test"
#wdio/runner: TypeError: hooks.map is not a function at Object.executeHooksWithArgs
There is a log-message indicating that both cucumber#6.0.5 and cucumber#7.0.0-rc.0 have moved to #cucumber/cucumber, so I tried
yarn remove cucumber
yarn remove #types/cucumber
yarn add -D #cucumber/cucumber
But I still get the same error message when trying to run the test, like nothing has changed. What am I doing wrong?

svelte and web3- ReferenceError: process is not defined

I am trying to add web3 functionality to my svelte app, but experience problems when importing the web3 module. Here is my package.json for reference:
{
"version": "0.0.1",
"type": "module",
"scripts": {
"test": "mocha",
"start": "PORT=3000 node build/",
"dev": "svelte-kit dev",
"dev-host": "svelte-kit dev --host",
"build": "svelte-kit build",
"preview": "svelte-kit preview",
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
},
"devDependencies": {
"#sveltejs/adapter-node": "^1.0.0-next.55",
"#sveltejs/kit": "next",
"#types/cookie": "^0.4.1",
"#typescript-eslint/eslint-plugin": "^4.31.1",
"#typescript-eslint/parser": "^4.31.1",
"dayjs": "^1.10.4",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^3.2.1",
"js-yaml": "^3.14.1",
"jsonwebtoken": "^8.5.1",
"password-hash": "^1.2.2",
"prettier": "^2.4.1",
"prettier-plugin-svelte": "^2.4.0",
"rehype-highlight": "^4.1.0",
"rehype-stringify": "^8.0.0",
"remark-frontmatter": "^3.0.0",
"remark-gfm": "^1.0.0",
"remark-parse": "^9.0.0",
"remark-rehype": "^8.0.0",
"sass": "^1.0.0",
"svelte": "^3.34.0",
"svelte-check": "^2.2.6",
"svelte-preprocess": "^4.9.4",
"to-vfile": "^6.1.0",
"tslib": "^2.3.1",
"typescript": "^4.4.3",
"unified": "^9.2.1",
"vite": "^2.1.0",
"mocha": "^9.1.2"
},
"dependencies": {
"#fontsource/fira-mono": "^4.5.0",
"better-sqlite3": "^7.4.4",
"cookie": "^0.4.1",
"solc": "^0.4.17",
"web3": "^1.6.0",
"#truffle/hdwallet-provider": "^1.5.1",
"fs-extra": "^10.0.0",
"ganache-cli": "^6.12.2"
}
}
I am basically trying to fetch a contract based on a addres
import web from './web3';
import Contract from './build/Contract.json';
export default (address) => {
return new web.eth.Contract(
JSON.parse(Contract.interface),
address
);
};
In my component.svelte i do:
<script>
import Contract from "../../../etherum/contract.js";
</script>
Which gives me the following error:
util.js:109 Uncaught (in promise) ReferenceError: process is not defined
at node_modules/util/util.js (util.js:109)
at __require2 (chunk-VPFHXPC5.js?v=bd5ef6bd:36)
at node_modules/web3-core-requestmanager/lib/index.js (index.js:20)
at __require2 (chunk-VPFHXPC5.js?v=bd5ef6bd:36)
at node_modules/web3-core/lib/index.js (index.js:22)
at __require2 (chunk-VPFHXPC5.js?v=bd5ef6bd:36)
at node_modules/web3/lib/index.js (index.js:29)
at __require2 (chunk-VPFHXPC5.js?v=bd5ef6bd:36)
at dep:web3:1
node_modules/util/util.js # util.js:109
__require2 # chunk-VPFHXPC5.js?v=bd5ef6bd:36
node_modules/web3-core-requestmanager/lib/index.js # index.js:20
__require2 # chunk-VPFHXPC5.js?v=bd5ef6bd:36
node_modules/web3-core/lib/index.js # index.js:22
__require2 # chunk-VPFHXPC5.js?v=bd5ef6bd:36
node_modules/web3/lib/index.js # index.js:29
__require2 # chunk-VPFHXPC5.js?v=bd5ef6bd:36
(anonymous) # dep:web3:1
await in (anonymous) (async)
(anonymous) # (index):273
The following way of doing imports in an react component works with this code:
import Contract from "../../ethereum/contract";
static async getInitialProps(props) {
const campaign = Contract(props.query.address);
What's the difference between how React handles this vs sveltekit?
And how do I solve this?
I was trying to use a secret dotenv environment variable via process.env.MYVAR inside a (vite-powered) sveltekit app, and learned that the right way to do that now in sveltekit is to import { env } from '$env/dynamic/private'; and only access it within a +page.server.js file's PageServerLoad() function
I found the best solution.
The problem is because you lose window.process somewhere in the development environment, and process exists only on node, not the browser.
So you should inject it to browser when the app loads.
Add this line to your app
window.process = {
...window.process,
};
I ended up with using svelte-web3 module instead.
I had the same problem and ran across this issue: https://github.com/vitejs/vite/issues/3817
In contradiction to this proposed solution, I found out that adding the following code in +layout.svelte instead of app.html is a working solution:
import process from "process";
import { Buffer } from "buffer";
import EventEmitter from "events";
import { browser } from "$app/environment";
if(browser) {
window.Buffer = Buffer;
window.process = process;
(window as any).EventEmitter = EventEmitter;
window.global = window
}

npm start: Manual browser refresh to reflect changes

I'm learning Node.js and in the introductory course, I had to set-up node and npm. Now according to the instructor, after typing "npm start" in the terminal and then making changes in the index.html file, the browser is supposed to automatically refresh the tab for the changes to take effect, but in my case every time I make a change I had to manually refresh Safari tab to see the changes.
Please note I'm using the same machine, i.e. there is no server and client side per se. Operating system is macOS Catalina 10.15.6.
Any possible fixes please?
Thanks
File Structure:
package.json file:
{
"name": "confusion",
"version": "1.0.0",
"description": "This is a website for Ristorante Con Fusion",
"main": "index.html",
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},
"author": "Raffay",
"license": "ISC",
"devDependencies": {
"lite-server": "^2.5.4"
},
"dependencies": {
"bootstrap": "^4.5.0",
"jquery": "^3.5.1",
"nodemon": "^2.0.4",
"popper.js": "^1.16.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/RaffaySajjad/conFusion.git"
},
"keywords": [
"conFusion"
],
"bugs": {
"url": "https://github.com/RaffaySajjad/conFusion/issues"
},
"homepage": "https://github.com/RaffaySajjad/conFusion#readme"
}
Starting nodemon from terminal using command "nodemon" prints following error
raffaysajjad#192 ~ % cd /Users/raffaysajjad/Desktop/Full\ Stack\ Web\ Development\ \(React\ Specialization\)/Course\ 1\ \(Front-End\ WebUI\ Frameworks\ \&\ Tools\ -\ Bootstrap\ 4\)/Week\ 1/Exercise/conFusion
raffaysajjad#192 conFusion % nodemon
[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: html,json
[nodemon] starting `node index.html`
/Users/raffaysajjad/Desktop/Full Stack Web Development (React Specialization)/Course 1 (Front-End WebUI Frameworks & Tools - Bootstrap 4)/Week 1/Exercise/conFusion/index.html:1
<!DOCTYPE html>
^
SyntaxError: Unexpected token '<'
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
[nodemon] app crashed - waiting for file changes before starting...
this is done by using the npm package of nodemon,
How to Use
npm install -g nodemon
and in your package.json use this
"scripts": {
"start": "nodemon npm run lite"
},
more about nodemon learn here
Yeah.Try installing nodemon.
npm install nodemon
It is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.
To run your server :
nodemon [your node app]
Nodemon will not helo you to browser reload for that kind of things you jest try plugins like connect-livereload
There are so many packages are there for this.
https://www.npmjs.com/package/reload
https://www.browsersync.io/

Can't compile assets with Gulp

Every tutorial or doc I find says that I should do something like this:
var elixir = require('laravel-elixir');
elixir.config.assetsPath = 'themes/ei/assets/src';
elixir.config.publicPath = 'themes/ei/assets/'
elixir(function(mix) {
mix.sass('style.scss');
mix.scripts('main.js');
});
But when I run gulp from the command line I get:
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (/home/andrew/Development/eiweb/node_modules/undertaker/lib/set-task.js:10:3)
at Gulp.task (/home/andrew/Development/eiweb/node_modules/undertaker/lib/task.js:13:8)
at Object.<anonymous> (/home/andrew/Development/eiweb/node_modules/laravel-elixir/dist/tasks/recipes/default.js:30:6)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:685:32)
at Function.Module._load (internal/modules/cjs/loader.js:620:12)
at Module.require (internal/modules/cjs/loader.js:723:19)
at require (internal/modules/cjs/helpers.js:14:16)
at requireDir (/home/andrew/Development/eiweb/node_modules/require-dir/index.js:123:33)
My package.json file includes:
"dependencies": {
"gulp": "^4.0.2",
"laravel-elixir": "^6.0.0-18"
}
...and I have gulp-cli installed global.
What am I missing?
This issue occurs because of version issue gulp 4 has different signature for the task and laravel-elixir uses old signature of gulp 3 so it will cause error.
Best case would be to move https://laravel-mix.com as its based on webpack so it support more functionalities. also laravel-mix syntax is similar so its plus point.
For laravel-mix create this pacjage package.json file in root. or user latest from [ https://github.com/laravel/laravel ] public repo.
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.18",
"bootstrap": "^4.1.0",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^4.0.7",
"lodash": "^4.17.5",
"popper.js": "^1.12",
"resolve-url-loader": "^2.3.1",
"sass": "^1.15.2",
"sass-loader": "^7.1.0",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.10"
}
}
Create webpack.mix.js in your root
const mix = require('laravel-mix');
// change theme path according to your need.
const themePath = 'themes/rainlab-bonjour';
mix.options({
publicPath: themePath + '/assets/compiled/'
})
// change script name and path according to your need.
mix.js(themePath + '/assets/src/main.js', 'main.js')
.sass(themePath + '/assets/src/main.scss', 'main.css');
Commands [ you can use this command with yarn or npm (I am using yarn)], you can read more info here. [ https://laravel-mix.com/docs/4.0/workflow ]
yarn watch -> it will watch files and compile files then generate compiled out-put in publicPath directory. in our case files will be.
themes/rainlab-bonjour/assets/compiled/main.js
themes/rainlab-bonjour/assets/compiled/main.css
Now you can just include them in theme using 'assets/compiled/main.js'|theme OctoberCms filter.
if you have any doubts please comment.

Unable to run npm install successfully due to karma: none was installed

I have package.json file in which following devDependencies are mentioned:
{ "name": "tabs-torico",
"version": "1.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.2",
"grunt-angular-templates": "~0.5.1",
"grunt-autoprefixer": "~0.4.0",
"grunt-cli": "~0.1.11",
"grunt-concurrent": "~0.4.1",
"grunt-connect-proxy": "~0.1.7",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-compass": "~0.6.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-cssmin": "~0.7.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-jshint": "~0.7.1",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "^0.5.3",
"grunt-karma": "~0.6.2",
"grunt-newer": "~0.5.4",
"grunt-ngmin": "~0.0.2",
"grunt-protractor-runner": "~0.2.1",
"grunt-rev": "~0.1.0",
"grunt-usemin": "~2.0.0",
"jasmine-core": "^2.6.2",
"jshint-stylish": "~0.1.3",
"karma": "^0.10.10",
"karma-chrome-launcher": "^0.1.12",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "^0.1.6",
"karma-ng-html2js-preprocessor": "~0.1.0",
"karma-ng-scenario": "~0.1.0",
"karma-requirejs": "~0.2.1",
"karma-script-launcher": "~0.1.0",
"load-grunt-tasks": "~0.2.0",
"phantomjs": "^2.1.7",
"phantomjs-prebuilt": "^2.1.14",
"protractor": "~0.18.1",
"requirejs": "~2.1.10",
"time-grunt": "~0.2.1"
},
"engines": {
"node": ">=0.8.0"
},
"scripts": {
"test": "grunt test"
}
}
Now when I run npm install gives me the following error:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY:
fsevents#github:pipobscure/fseve
nts#7dcdf9fa3f8956610fd6f69f72c67bace2de7138
(node_modules\chokidar\node_modules
\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents#
0.2.1: wanted {"os":"darwin","arch":"any"} (current:
{"os":"win32","arch":"x64"}
)
npm WARN karma#0.10.10 requires a peer of karma-coffee-preprocessor#~0.1.0
but none was installed.
npm WARN karma#0.10.10 requires a peer of karma-firefox-launcher#~0.1.0 but
none was installed.
npm WARN karma#0.10.10 requires a peer of karma-phantomjs-launcher#~0.1.0
but none was installed.
Will running npm install install all the dependencies mentioned in the package.json or do I need to install jasmine-core and karma-jasmine separately?
npm install installs all the dependencies specified in your package.json. You should find the in your node_modules folder.
It's the problem with your version of karma.
In the package.json file includes the following line instead of the current line of karma.
"karma": "^0.11.14"
Also, it is important to note that if you are using karma-chrome-launcher
you need to include that as well in your package.json file as the new version of karma doesn't come with it.
So include the following line as well.
"karma-chrome-launcher": "^0.1.2"
I hope this will solve your problem.