In QTP, there is a concept called “Object Repository”. All the objects are added to Object Repository and the objects are used in the test. If there are any changes in the application then we need to update only Object Repository. But in selenium WebDriver, There is no any built-in facility to create object repository. So maintenance of page objects(Page element locators) becomes very hard If you will write all objects of page on code level.
Exporting UFT 12 results into html throws the error about 'IDS_BC'
Exporting UFT 12 results into html throws the error “A reference to variable or parameter ‘IDS_BC’ cannot be resolved.”
I have recently upgraded from QTP 11 to UFT 12. The vbscript I used for QTP 11 worked great, but it is not running with UFT 12.
使用Java操作MongoDB - Insert ISODate
We could insert data with json as:1
2
3
4
5
6
7
8
9
10
11
12{
"name_collection1": [
{
"attribute_1":"value1",
"attribute_2":"value2"
},
{
"attribute_3":2,
"attribute_4":"value4"
}
]
}
If you want to use ISODate function or any other javascript function you should see how MongoDB Java Driver deals with it. For example in case of ISODate:1
"bornAt":{ "$date" : "2015-01-05T10:09:15.210Z"}
使用Java操作MongoDB - Query
Query1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68Mongo mg = new Mongo("localhost", 27017);
// get db
db = mg.getDB("CRUD");
// get collection
dc = db.getCollection("test");
// findOne
System.out.println(dc.findOne());
// find all
DBCursor cursor = dc.find();
while(cursor.hasNext()){
System.out.println(cursor.next());
}
// display certain column
BasicDBObject keys = new BasicDBObject();
keys.put("name", 1);
keys.put("_id", 0);
DBCursor cursor = dc.find(new BasicDBObject(), keys);
while (cursor.hasNext()) {
System.out.println(cursor.next());
}
// equal | greater | less | not equal | regex
BasicDBObject query = new BasicDBObject();
//query.put("name", "hulu1");
//query.put("number", new BasicDBObject("$gt", 2));
//query.put("number", new BasicDBObject("$gte", 2));
//query.put("number", new BasicDBObject("$lt", 5));
//query.put("number", new BasicDBObject("$lte", 5));
//query.put("name", new BasicDBObject("$ne", "hulu1"));
query.put("name", new BasicDBObject("$regex", "hulu.*"));
DBCursor cursor = dc.find(query);
while (cursor.hasNext()) {
System.out.println(cursor.next());
}
// in | not in
BasicDBObject query = new BasicDBObject();
List<String> list = new ArrayList<String>();
list.add("hulu1");
list.add("hulu4");
query.put("name", new BasicDBObject("$nin", list));
DBCursor cursor = dc.find(query);
while (cursor.hasNext()) {
System.out.println(cursor.next());
}
// and
BasicDBObject query = new BasicDBObject();
query.put("number", new BasicDBObject("$gt", 2));
query.put("name", "hulu1");
DBCursor cursor = dc.find(query);
while (cursor.hasNext()) {
System.out.println(cursor.next());
}
// or
BasicDBObject query = new BasicDBObject();
List<BasicDBObject> obj = new ArrayList<BasicDBObject>();
obj.add(new BasicDBObject("name", "hulu1"));
obj.add(new BasicDBObject("number", new BasicDBObject("$gt", 2)));
query.put("$or", obj);
DBCursor cursor = dc.find(query);
while (cursor.hasNext()) {
System.out.println(cursor.next());
}
使用Java操作MongoDB - Update
Update1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18Mongo mg = new Mongo("localhost", 27017);
// get db
db = mg.getDB("CRUD");
// get collection
dc = db.getCollection("test");
//Update
BasicDBObject query = new BasicDBObject();
query.put("name", "hulu22");
query.put("title", "PO");
BasicDBObject newDoc = new BasicDBObject();
newDoc.put("$set", new BasicDBObject("title", "PM").append("name", "hulu22"));// $unset: Removes the specified field from a document.
dc.update(query, newDoc);
dc.update(query, newDoc, false, false);
dc.updateMulti(query, newDoc);