Ask a Question

couldn't use mongo db drivers

Frequent Contributor

couldn't use mongo db drivers

I downloaded both async and sync drivers from here

I import my drivers in classpath(current project), I set java VM.

I use this code, but I couldn't see any obyect.

async function main() {
var MongoClient = require('mongodb')
var client = await MongoClient.connect('mongodb://string<1>:<string2>:10255/?ssl=true&appName=@user@')
var db = client.db('dlc-dev-cosmos')
var collection = db.collection('batteries')

var docs = await collection.find({}).limit(5).toArray()
await client.close()


Could help me

Community Hero

If I understand you correctly, you are trying to get Java methods from the mongoDB driver, right?


The internal example you are referring to:


var MongoClient = require('mongodb')


What's in the Mongodb file?


Did you do it together with this manual?

SmartBear Alumni (Retired)

Hi @msalvador,


Could you please clarify what you mean by "I couldn't see any object"? Where don't you see objects? If you are talking about Code Completion, I'm not sure if TestComplete shows objects from external libraries.



Tanya Yatskovskaya
SmartBear Community and Education Manager

Hi tanya,

What I wrote in my first post is not correct, now I clarify the situation.

I download with this command: npm i –save mongodb     the mongo bd libraries(find in attachment,

This libraries in filesystem have a tree structure.

Then I run the function you find in the firt post, but it doesn't work.

I tried to import libreries in my project but have a tree structure and don't work.

I post a picture about my project explore

I think you need some more infos, so please reply me

Esteemed Contributor

If Mongdb is a javascript file, you need to actually add it to the project.  In your tree structure, I don't see it anywhere so calling requires("mongodb") won't work.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Frequent Contributor

MongoDB is a father root that contains all the libraries, in the javascript files, there is this call Require(.\<folder1>\<folder2>\xxx.js), and as I can see this not work importing in my project.

I schift to another solution... java libraries, so I imported them in java bridge panel and use them.

SmartBear Alumni (Retired)

Thanks everyone for the help!


@msalvador, I'm happy to hear that you've found the solution 🙂 . Thanks for sharing it with us.



Tanya Yatskovskaya
SmartBear Community and Education Manager

Frequent Contributor

yes external function

Hi Tanya,

in attachment the picture of external libraries imported and a snippet.

Showing results for 
Search instead for 
Did you mean: