MongoDB and QTP




Problem: Tried connecting QTP with MongoDB [No SQL database]?

  1. You can connect to MongoDB using .net/java languages since there are drivers for it.
  2. In QTP (VBScript) you can then call those drivers. 
  3. You can create a java jar which exposes methods like connect, execute, disconnect etc on MongoDB and call them from vbscript.

Solution:  


1. Get a Code snippet in Java where it connects with Mongo DB,Insert/Select/Update..etc

2. Run the below code which will then give the result in a file.

Systemutil.Run "cmd.exe"
Window("object class:=ConsoleWindowClass").Maximize
window("object class:=ConsoleWindowClass").Type "cd\Test Result"
window("object class:=ConsoleWindowClass").Type micReturn
window("object class:=ConsoleWindowClass").Type "java -classpath C:\Users\Ady\Desktop\QTPMongo\bin;C:\Users\Ady\Desktop\QTPMongo\lib\mongo-2.10.1.jar com.jpmc.cfp.mongo.MongoSearchMain> output.xls"

We can customize the output based on our need and improve the script based on the use case

Comments

  1. Can you give me the sample JAR file for Mongo DB connection?

    ReplyDelete

Post a Comment

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?