-
Notifications
You must be signed in to change notification settings - Fork 0
/
Selenium Practice.txt
185 lines (142 loc) · 4.08 KB
/
Selenium Practice.txt
1
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
SELENIUM PRACTICE:
public class Test {
int a = 1, b = 2;
public void add() {
int sum = a + b;
int diff = a - b;
System.out.println("sum:" + sum + "diff:" + diff);
// System.out.println("diff:" + diff );
}
public static void main(String[] args) {
Test t = new Test();
t.add();
}
}
=====================================================================
CatalogItem.java
/**
*
*/
package com.zycus.training.collections;
/**
* @author ankita.sawant
*
*/
public class CatalogItem {
String itemName;
int quantity;
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
=====================================================================
Items.java
package com.zycus.training.collections;
import java.util.ArrayList;
import java.util.List;
public class Items {
public List<CatalogItem> catalogItems = new ArrayList<>();
public List<CatalogItem> getCatalogItems() {
return catalogItems;
}
public void setCatalogItems(List<CatalogItem> catalogItems) {
this.catalogItems = catalogItems;
}
}
=====================================================================
TestCollections.java
/**
*
*/
package com.zycus.training.collections;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.map.HashedMap;
/**
* @author ankita.sawant
*
*/
public class TestCollections {
public static void main(String[] args) {
// to create list
List<String> list = new ArrayList<>();
// add elements in list
list.add("B");
list.add("D");
list.add("A");
list.add("C");
// print size of list
System.out.println("Size : " + list.size());
// to remove element from list
list.remove("B");
System.out.println("Size after removing element : " + list.size());
// iterator for collection
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
String var = iterator.next().toString();
System.out.println(var);
if (var.equalsIgnoreCase("A")) {
System.out.println("Search successful");
break;
}
}
System.out.println("Exit");
// arraylist : can contain values of any datatype
ArrayList list2 = new ArrayList<>();
list2.add(2);
list2.add("A");
list2.add(5.02);
// to create linked list
LinkedList<String> list3 = new LinkedList<>();
// to create hash map
Map<String, String> map = new HashedMap();
// to add values in map
map.put("Req Name", "REQ_456");
map.put("Buyer Name", "ABC");
map.put("Settlement Via", "Invoice");
// to get value from map
System.out.println(map.get("Buyer Name"));
// to print all values of map
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getKey() + " : " + entry.getValue());
}
// linked hash map
LinkedHashMap<String, Integer> map2 = new LinkedHashMap<>();
map2.put("First", 1);
map2.put("Second", 2);
map2.put("Third", 3);
System.out.println(map2.get("Second"));
for (Map.Entry<String, Integer> entry : map2.entrySet()) {
System.out.println(entry.getKey() + " : " + entry.getValue());
}
// to create object of catalog item : laptop
CatalogItem catalogItem = new CatalogItem();
catalogItem.setItemName("Laptop");
catalogItem.setQuantity(5);
// to create object of catalog item : Mobile
CatalogItem catalogItem2 = new CatalogItem();
catalogItem2.setItemName("Mobile");
catalogItem2.setQuantity(10);
// map of catalog items
Map<String, CatalogItem> map3 = new HashedMap();
map3.put("Laptop", catalogItem);
map3.put("Mobile", catalogItem2);
// list of catalog items
List<CatalogItem> catalogItems = new ArrayList<>();
catalogItems.add(catalogItem);
catalogItems.add(catalogItem2);
}
}