Connection between through MongoDB and Selenium Web Driver
Code for search any record in mongo db collection
Search record in "LAMPSTACKRESPONSE" collection
Use mongo-2.10.1 jar file in your project directory
// To connect to mongodb server
MongoClient mongoClient = new MongoClient("172.16.1.203" , 27017 );
// Now connect to your databases
DB db = mongoClient.getDB("ritesh");
char[] password = new char[] {'s', 'p', 'a', 't', 'e', 's','t'};
boolean authenticated = db.authenticate("ritesh", password);
if (authenticated) {
System.out.println("Successfully logged in to MongoDB!");
} else {
System.out.println("Invalid username/password");
}
BasicDBObject account = null;
DBCollection coll = db.getCollection("LAMPSTACKRESPONSE");
DBCursor cursor = coll.find();
// Get documents by query
BasicDBObject query = new BasicDBObject("logicName",getlogicname);
cursor = coll.find(query);
int recordCount=cursor.count();
System.out.println("Count of web site--> "+recordCount);
if(recordCount >= 2)
{
Assert.assertEquals("scale up done","scale up done");
}
else
{
Assert.assertEquals("Scale up not done","Scale up not done on another platform");
}
Code for search any record in mongo db collection
Search record in "LAMPSTACKRESPONSE" collection
Use mongo-2.10.1 jar file in your project directory
// To connect to mongodb server
MongoClient mongoClient = new MongoClient("172.16.1.203" , 27017 );
// Now connect to your databases
DB db = mongoClient.getDB("ritesh");
char[] password = new char[] {'s', 'p', 'a', 't', 'e', 's','t'};
boolean authenticated = db.authenticate("ritesh", password);
if (authenticated) {
System.out.println("Successfully logged in to MongoDB!");
} else {
System.out.println("Invalid username/password");
}
BasicDBObject account = null;
DBCollection coll = db.getCollection("LAMPSTACKRESPONSE");
DBCursor cursor = coll.find();
// Get documents by query
BasicDBObject query = new BasicDBObject("logicName",getlogicname);
cursor = coll.find(query);
int recordCount=cursor.count();
System.out.println("Count of web site--> "+recordCount);
if(recordCount >= 2)
{
Assert.assertEquals("scale up done","scale up done");
}
else
{
Assert.assertEquals("Scale up not done","Scale up not done on another platform");
}
No comments:
Post a Comment