I have one application which are used node js. In which I have used selenium webdriverIO for testing purpose but when I write a script using selenium webdriverIO it and using INIT function it will generate error "TypeError:INIT is not a function". Please give solution for this code
TypeError: webdriverio.remote(...).init is not a function
at Object. (E:\WebdriverIOAutomation\test\specs\WithoutWdioClient.js:11:6)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
var webdriverio = require('webdriverio');
var options = {
desiredCapabilities: {
browserName: 'chrome'
}
};
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
.title(function(err, res) {
console.log('Title was: ' + res.value);
})
.end();
Expected Result: Get Title of Google
Actual Result: Generate Error of INIT Function
Related
Hello (I am very new to programming!)
I keep getting this error message (below) whenever I try to run my bot in CMD.
(Scroll down for code and error and stuff) I am super confused about all of this!
I tried fixing it by removing the ; but that didn't work, it told me the ) was unexpected, but when I removed the ) it told me it was needed!
Code Block One:
// Runs on bot start
bot.on('ready', () => {
// Now we post into the console that the bot has been turned on.
console.log('Bot turned on in the CMD')
});
Code Block Two: (Semi-Colon Removed)
// Runs on bot start
bot.on('ready', () => {
// Now we post into the console that the bot has been turned on.
console.log('Bot turned on in the CMD')
})
Code Block Three:
bot.on('ready', () => {
// Now we post into the console that the bot has been turned on.
console.log('Bot turned on in the CMD')
}
Expected Result:
Bot turns on, sends a message in the CMD to that effect.
Error #1 (See code block 1 to find the code)
`C:\Users\xgoul\OneDrive\Desktop\Discord Bot\app.js:74
});
^
SyntaxError: Unexpected end of input
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)`
Error #2 (See code block 2 to find the code)
`C:\Users\xgoul\OneDrive\Desktop\Discord Bot\app.js:74
})
^
SyntaxError: Unexpected end of input
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)`
Error #3 (See code block 3 to find the code)
`C:\Users\XXXX\OneDrive\Desktop\Discord Bot\app.js:74
}
^
SyntaxError: missing ) after argument list
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)`
Code block 1 is correct, its returning unexpected end of input because you have to include a return statement.
// Runs on bot start
bot.on('ready', () => {
// Now we post into the console that the bot has been turned on.
console.log('Bot turned on in the CMD');
return('whatever');
});
I am trying to use a typescript-parser:
https://www.npmjs.com/package/typescript-parser
but I'm having difficulties with using the package properly.
I installed the package successfully using npm install; when I run npm list --depth=0 it shows up in the list.
Eventually, I tried running the following line of code that is suggested in the link attached above (using node command):
const parser = new TypescriptParser();
but the problem is that I get the following error:
const parser = new TypescriptParser();
^
ReferenceError: TypescriptParser is not defined
at Object.<anonymous> (C:\Users\...\parser_example.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Alternatively, I tried running this:
const TypescriptParser = require('typescript-parser');
const parser = new TypescriptParser();
yet I still get a (different) error:
const parser = new TypescriptParser();
^
TypeError: TypescriptParser is not a constructor
at Object.<anonymous> (C:\Users\...\parser_example.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
It seems as if although the package was installed, it doesn't recognize the class TypescriptParser.
Any help would be much appreciated!
Try importing using:
import { TypescriptParser } from 'typescript-parser';
I tried the code below and it works for me :
index.js file
const parser = require('typescript-parser');
const parser = new TypescriptParser();
I run it with node index.js
This code works for me:
index.js file
const tp = require('typescript-parser');
const parser = new tp.TypescriptParser();
I'm using node backend and am trying to connect to plaid.
My code:
var plaid = require('plaid');
var clientID = "bla";
var secretID = "bla";
var publicKey = "bla";
var client = new plaid.Client(
clientID,
secretID,
publicKey,
plaid.environments.sandbox
);
However I am getting this error in my console:
throw new Error('Invalid Plaid environment');
^
Error: Invalid Plaid environment
at new Plaid.Client (C:\Users\me\Documents\found\SPA\node_modules\plaid\index.js:26:11)
at module.exports (C:\Users\me\Documents\found\SPA\app\routes.js:48:22)
at Object.<anonymous> (C:\Users\me\Documents\found\SPA\server.js:48:24)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
I have tried using each of these with no luck:
plaid.environments.sandbox
plaid.environments.development
plaid.environments.tartan
What's going on?
Ref: https://plaid.com/docs/quickstart/#accessing-item-data
UPDATE:
I've gotten this code below to work in another part of my app:
var plaidClient = new plaid.Client(clientID, secretID, plaid.environments.tartan);
However I am trying to use client.getTransactions() and it is required to have var plaidClient = new plaid.Client(clientID, secretID, publicID, plaid.environments.sandbox);
in order for client.getTransactions() to work.
UPDATE?
For some reason I had the wrong version of plaid installed. I needed to uninstall and reinstall to fix. Works now.
just want to learn Selenium testing beginning with it's own sample.
However, after everything is set up(Node.js, Selenium), when I want to use selenium-webdriver's own sample, it is not working:
This is the official code(name is google_search.js) provided by selenium:
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder()
.forBrowser('firefox')
.build();
driver.get('http://www.google.com/ncr');
driver.findElement(By.name('q')).sendKeys('webdriver');
driver.findElement(By.name('btnG')).click();
driver.wait(until.titleIs('webdriver - Google Search'), 1000);
driver.quit();
This code is within example folder, in Node.js cmd, I cd to node_modules\selenium-webdriver\example, and put geckodriver in this folder, then run node google_search.js
Here's the result:
C:\Users\username\node_modules\selenium-webdriver\lib\promise.js:2291
throw error;
^
WebDriverError: Unable to parse new session response: {"error":"unknown error","
message":"Expected browser binary location, but unable to find binary in default
location, no 'firefox_binary' capability provided, and no binary flag set on th
e command line"}
at WebDriverError (C:\Users\username\node_modules\selenium-webdriver\lib\err
or.js:27:10)
at C:\Users\username\node_modules\selenium-webdriver\lib\http.js:335:17
at process._tickCallback (node.js:369:9)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\username\node_modules\selenium-webdriver
\lib\webdriver.js:366:24)
at createGeckoDriver (C:\Users\username\node_modules\selenium-webdriver\fire
fox\index.js:497:27)
at Driver (C:\Users\username\node_modules\selenium-webdriver\firefox\index.j
s:605:14)
at Builder.build (C:\Users\username\node_modules\selenium-webdriver\index.js
:557:16)
at Object.<anonymous> (C:\Users\username\node_modules\selenium-webdriver\exa
mple\google_search.js:44:6)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
From: Task: WebDriver.navigate().to(http://www.google.com/ncr)
at Driver.schedule (C:\Users\username\node_modules\selenium-webdriver\lib\we
bdriver.js:414:17)
at Navigation.to (C:\Users\username\node_modules\selenium-webdriver\lib\webd
river.js:1042:25)
at Driver.get (C:\Users\username\node_modules\selenium-webdriver\lib\webdriv
er.js:832:28)
at Object.<anonymous> (C:\Users\username\node_modules\selenium-webdriver\exa
mple\google_search.js:46:8)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
Did I do anything wrong? Can anyone tell me why the offical sample is not launching firefox? Thanks!
I had the same error-message when trying to run a C#-application with Selenium 3.0.0.
The problem was that I was using the x64 Geckodriver.exe. After downloading and copying the 32bit version to my bin-folder, everything worked well.
-Robert
This question is not the same as Extended Errors do not have message or stack trace, which deals with es6 extends, but I'm using es5.
Here's my code
test.js
function FooError(message) {
this.stack = (new Error(message)).stack;
console.log('this.stack', this.stack);
console.log('new_error_stack', (new Error(message)).stack);
console.log('after');
}
FooError.prototype = new Error;
throw new FooError("foo");
This gives the following output : with node version 6.4 (node test.js)
this.stack Error
at Object.<anonymous> (/tmp/test.js:7:22)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
new_error_stack Error: foo
at Error.FooError (/tmp/test.js:4:33)
at Object.<anonymous> (/tmp/test.js:9:7)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
after
/tmp/test.js:9
throw new FooError("foo");
^
Error
at Object.<anonymous> (/tmp/test.js:7:22)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
as you can see, the 'this.stack' doesn't show the same thing at all than the 'new_error_stack', eg, the this.stack shows the stack as if the error was thrown when the require was called. Also, the thrown stack is also "incorrect".
I took the code from https://stackoverflow.com/a/5251506/1993501 , and since I want to use instanceof FooError, I use the line FooError.prototype = new Error.
As you can see, the 'new_error_stack' gives the expected output, but I would have expected both values to be equal.
This has the effect that errors are not very useful for users of my library, see corresponding issue : https://github.com/open-xml-templating/docxtemplater/issues/245
What exactly is happening, and how can I prevent it and keep proper error types (eg being able to use instanceof) ?
I found a possible solution to your problem, but I'm not entirely sure it fixes all of your issues. I'm using Error.prototype instead of new Error (which is what you had). I found this solution from the first answer provided to this question: How do I create a custom Error in JavaScript?
I also changed your console.log lines to concatenate the two strings, as I was using alert() to display the output for testing purposes.
Kevin Hakanson goes over why you may or may not want to go with this solution in his answer. Here's the code to answer your question:
function FooError(message) {
this.stack = (new Error(message)).stack;
console.log('this.stack ' + this.stack);
console.log('new_error_stack ' + (new Error(message)).stack);
console.log('after');
}
FooError.prototype = Error.prototype;
throw new FooError("foo");
You may want to use a try/catch block with that last line.