UnhandledPromiseRejectionWarning: NoSuchElementError: no such element: Unable to locate element - node.js

var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().forBrowser('chrome').build();
driver.get('http://www.google.com');
driver.findElement({name: 'q'}).sendKeys('webdriverjs');
driver.findElement({name: 'q'}).sendKeys(webdriver.Key.ENTER);
driver.manage().window().maximize();
driver.wait(webdriver.until.elementLocated({xpath: '//*[#id="rso"]/div/div/div[1]/div/div/h3/a'}), 30000);
driver.findElement({xpath: '//*[#id="rso"]/div/div/div[1]/div/div/h3/a'}).click();
Getting the following error:
DevTools listening on ws://127.0.0.1:12148/devtools/browser/86604bd8-c770-4659-bdaf-0abbf4cd790c
(node:15596) UnhandledPromiseRejectionWarning: NoSuchElementError: no such element: Unable to locate element: {"method":"xpath","selector":"//*[#id="rso"]/div/div/div[1]/div/div/h3/a"}
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 10.0.16299 x86_64)
at Object.checkLegacyResponse (C:\Users\SPal\webdriverjs\node_modules\selenium-webdriver\lib\error.js:585:15)
at parseHttpResponse (C:\Users\SPal\webdriverjs\node_modules\selenium-webdriver\lib\http.js:533:13)
at Executor.execute (C:\Users\SPal\webdriverjs\node_modules\selenium-webdriver\lib\http.js:468:26)
at
at process._tickCallback (internal/process/next_tick.js:182:7)
(node:15596) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15596) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Related

UnhandledPromiseRejectionWarning: MongooseError: Connection 0 was disconnected when calling `startSession

I'm working with MongoDB to save data using transactions.But its giving the below error.
(node:29448) UnhandledPromiseRejectionWarning: MongooseError: Connection 0 was disconnected when calling `startSession`
at NativeConnection.startSession (D:\Rubix\rubixkyc\node_modules\mongoose\lib\connection.js:565:31)
at D:\Rubix\rubixkyc\server\util\route_utils.js:35:38
at new Promise (<anonymous>)
at saveKycData (D:\Rubix\rubixkyc\server\util\route_utils.js:32:12)
at D:\Rubix\rubixkyc\server\controllers\bulk_gst_verification_controller.js:48:19
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
at processPromiseRejections (internal/process/promises.js:247:11)
at processTicksAndRejections (internal/process/task_queues.js:96:32)
[RUBIX KYC] 27-12-2022 07:44:37.193 PM [info]: <server\controllers\bulk_gst_verification_controller.js:46> saving GST verification data ....
(node:29448) MongooseError: Connection 0 was disconnected when calling `startSession`
at NativeConnection.startSession (D:\Rubix\rubixkyc\node_modules\mongoose\lib\connection.js:565:31)
at D:\Rubix\rubixkyc\server\util\route_utils.js:35:38
at new Promise (<anonymous>)
at saveKycData (D:\Rubix\rubixkyc\server\util\route_utils.js:32:12)
at D:\Rubix\rubixkyc\server\controllers\bulk_gst_verification_controller.js:48:19
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:29448) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:180:11)
at processPromiseRejections (internal/process/promises.js:249:13)
at processTicksAndRejections (internal/process/task_queues.js:96:32)
Sharing the image of the code snippet.
Note:- This started happening after i started using worker pool for concurrency.
This save method i
const workerpool = require('workerpool');
Please help me with the issue

Why telegram bot don't work if participants left group or new one add to group?

When I run my app and someone in group left or new participant add to group, my bot stop working.
Below you can see code of my app:
const TelegramBot = require('node-telegram-bot-api');
const token = '1928095766:AAGf5aU7E1_FAM_fWzQs3SSGy-1AJS0DjcY';
const bot = new TelegramBot(token, { polling: true });
bot.on('message', async msg => {
const reg = /\d\d\-\d\d$/;
if (msg.text.match(reg)) {
bot.sendMessage(msg.chat.id, 'Gh')
}
})
And what I received in terminal if someone left group or new one add into, when my app is running:
(node:21155) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'match' of undefined
at TelegramBot.<anonymous> (/Users/romansavka/Telegram-Bot-Node/telegram-bot/reminder.js:11:30)
at TelegramBot.emit (/Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/eventemitter3/index.js:182:35)
at TelegramBot.processUpdate (/Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/node-telegram-bot-api/src/telegram.js:634:12)
at /Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/node-telegram-bot-api/src/telegramPolling.js:110:22
at Array.forEach (<anonymous>)
at /Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/node-telegram-bot-api/src/telegramPolling.js:106:17
at tryCatcher (/Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues (/Users/romansavka/Telegram-Bot-Node/telegram-bot/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:462:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:21155) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:21155) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
It's because the message received has no attribute text, so the error raised UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'match' of undefined

Discord.js bot errors involving embedded images

So I programmed a discord bot to, on command, send a randomly selected gif from a folder in an embedded message. It worked fine until I started trying to host the bot from Heroku. Now the command does nothing but displays an error in the log saying something like "could not find file extension", "deprecation error", or, just now, "unhandled promise rejection". My main issue is that I'm very new to programming in general, so I have no clue what exactly my problem is, let alone how to resolve it.
This is the current code I have for this particular section:
case '//command':
const Embed = new MessageEmbed()
var number = 43;
var imageNumber = Math.floor (Math.random()*(number-1+1))+1
Embed.setTitle("//message")
Embed.setDescription("//message")
Embed.attachFiles({files: ["./images/" + imageNumber + ".gif"]})
Embed.setImage("attachment://" + imageNumber + ".gif")
Embed.setColor(0x9B00C3)
msg.channel.send(Embed)
break;
Edit: as requested, here is the error message that appears:
2020-07-11T17:23:22.063132+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'path' of undefined
2020-07-11T17:23:22.063143+00:00 app[web.1]: at findName (/app/node_modules/discord.js/src/structures/APIMessage.js:273:17)
2020-07-11T17:23:22.063144+00:00 app[web.1]: at Function.resolveFile (/app/node_modules/discord.js/src/structures/APIMessage.js:289:31)
2020-07-11T17:23:22.063145+00:00 app[web.1]: at /app/node_modules/discord.js/src/structures/APIMessage.js:224:72
2020-07-11T17:23:22.063147+00:00 app[web.1]: at Array.map (<anonymous>)
2020-07-11T17:23:22.063147+00:00 app[web.1]: at APIMessage.resolveFiles (/app/node_modules/discord.js/src/structures/APIMessage.js:224:46)
2020-07-11T17:23:22.063148+00:00 app[web.1]: at TextChannel.send (/app/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:172:46)
2020-07-11T17:23:22.063149+00:00 app[web.1]: at Client.<anonymous> (/app/index.js:76:25)
2020-07-11T17:23:22.063149+00:00 app[web.1]: at Client.emit (events.js:315:20)
2020-07-11T17:23:22.063149+00:00 app[web.1]: at MessageCreateAction.handle (/app/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
2020-07-11T17:23:22.063150+00:00 app[web.1]: at Object.module.exports [as MESSAGE_CREATE] (/app/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
2020-07-11T17:23:22.063226+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
2020-07-11T17:23:22.063337+00:00 app[web.1]: (node:23) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Promise callback could not be found

I am trying to use chainpoint. I have a few hashes and am trying to submit them to chainpoint to create a timestamp proof and then anchor them to a public blockchain.
I am using the github tutorial https://github.com/chainpoint/chainpoint-js
But I am getting an error as
(node:8796) UnhandledPromiseRejectionWarning: Error: Argument must be
a non-empty Array
at S (C:\Users\Unmesha Banarjee\node_modules\chainpoint-js\dist\bundle.js:1:6002)
at H (C:\Users\Unmesha Banarjee\node_modules\chainpoint-js\dist\bundle.js:1:6533)
at de (C:\Users\Unmesha Banarjee\node_modules\chainpoint-js\dist\bundle.js:1:15276)
at Module. (C:\Users\Unmesha Banarjee\node_modules\chainpoint-js\dist\bundle.js:1:15596)
at tryCatch (C:\Users\Unmesha Banarjee\node_modules\regenerator-runtime\runtime.js:45:40)
at Generator.invoke [as _invoke] (C:\Users\Unmesha Banarjee\node_modules\regenerator-runtime\runtime.js:274:22)
at Generator.prototype.(anonymous function) [as next] (C:\Users\Unmesha
Banarjee\node_modules\regenerator-runtime\runtime.js:97:21)
at me (C:\Users\Unmesha Banarjee\node_modules\chainpoint-js\dist\bundle.js:1:15336)
at a (C:\Users\Unmesha Banarjee\node_modules\chainpoint-js\dist\bundle.js:1:16954)
at C:\Users\Unmesha Banarjee\node_modules\chainpoint-js\dist\bundle.js:1:17015 (node:8796)
UnhandledPromiseRejectionWarning: Unhandled promise rejection. This
error originated either by throwing inside of an async function
without a catch block, or by rejecting a promise which was not handled
with .catch(). (rejection id: 2) (node:8796) [DEP0018]
DeprecationWarning: Unhandled promise rejections are deprecated. In
the future, promise rejections that are not handled will terminate the
Node.js process with a non-zero exit code.
Can anyone help me...

Parse Sever with custom Express app Master Key Permission Denied

We have a custom express app that loads in the node.js parse server sdk. When we try to use a function call that requires the master key we keep getting errors for permission denied.
at /Users/gateway/Documents/lm/Website/lm-node/node_modules/parse/lib/node/RESTController.js:324:19
at processTicksAndRejections (internal/process/task_queues.js:86:5)
(node:61092) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:61092) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
we initiate our parse server like this..
Parse.initialize(process.env.PARSE_STAGING_APP_ID, null, process.env.PARSE_STAGING_MASTER_KEY);
//Parse.Cloud.useMasterKey();
Parse.serverURL = process.env.PARSE_STAGING_SERVER_URL;
Parse.User.enableUnsafeCurrentUser();
module.exports = Parse
async function channelStatus(orgId) {
const Status = Parse.Object.extend("Status");
const query = new Parse.Query(Status);
query.equalTo("orgID", orgId);
try {
const results = await query.first({useMasterKey: true});
if(results) {
// do some stuff
results.save();
} else {
const StatusNew = Parse.Object.extend("Status");
const statusNew = new StatusNew();
// do some stuff
statusNew.save()
}
} catch (error) {
throw error;
}
}
if we enable Parse.Cloud.useMasterKey(); it works but this can be bad because it works for every function.. we want to make sure we are using masterKey on certain functions..
thoughts?
full error in visual studio.
(node:35145) UnhandledPromiseRejectionWarning: Error: Permission denied for action get on class Status.
at /Users/gateway/Documents/lmx/WebSite/lmx/node_modules/parse/lib/node/RESTController.js:324:19
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:35145) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:35145) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
GET /test - - ms - -
Logs
Jul 29 13:08:29 lmx-stage app/web.1: error: Error generating response. ParseError {
Jul 29 13:08:29 lmx-stage app/web.1: code: 119,
Jul 29 13:08:29 lmx-stage app/web.1: message: 'Permission denied for action get on class Status.' } code=119, message=Permission denied for action get on class Status.
Jul 29 13:08:29 lmx-stage app/web.1: error: Permission denied for action get on class Status. code=119, message=Permission denied for action get on class Status.

Resources