forked from CourseRepository/SeleniumWebdriverWithJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeywordSteps.java
More file actions
96 lines (76 loc) · 2.45 KB
/
KeywordSteps.java
File metadata and controls
96 lines (76 loc) · 2.45 KB
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
/**
*
*/
package Keyword;
import helper.ButtonHelper;
import helper.ComboBoxHelper;
import helper.GenericHelper;
import helper.LinkHelper;
import helper.TextBoxHelper;
import helper.customexceptions.KeyWordNotFoundException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* @author - rahul.rathore
* @date - 13-Jun-2015
* @project - Webdriver
* @package - keyword
* @file name - keywordsteps.java
*/
public class KeywordSteps{
private static FileInputStream xlStream;
private static XSSFWorkbook book;
private static XSSFSheet sheet;
private static XSSFRow row;
public static void readExcelPerformAction(String aFilePath,String bSheetName) {
try {
xlStream = new FileInputStream(new File(aFilePath));
book = new XSSFWorkbook(xlStream);
sheet = book.getSheet(bSheetName);
for(int i = 2; i <= sheet.getLastRowNum(); i++){
row = sheet.getRow(i);
switch (row.getCell(0).getStringCellValue()) {
case "Click":
LinkHelper.clickLink(row.getCell(2).getStringCellValue());
break;
case "TextBox":
TextBoxHelper.typeUsingKeyWord(row.getCell(1).getStringCellValue(), row.getCell(2).getStringCellValue(), row.getCell(3).getStringCellValue());
break;
case "Button click":
ButtonHelper.clickUsingKeyWord(row.getCell(1).getStringCellValue(), row.getCell(2).getStringCellValue());
break;
case "Select":
ComboBoxHelper.selectByKeyWord(row.getCell(1).getStringCellValue(), row.getCell(2).getStringCellValue(), row.getCell(3).getStringCellValue());
break;
case "Radio Button":
ButtonHelper.clickUsingKeyWord(row.getCell(1).getStringCellValue(), row.getCell(2).getStringCellValue());
break;
case "WaitForEle":
GenericHelper.waitForElement(row.getCell(2).getStringCellValue(), (int)row.getCell(3).getNumericCellValue());
break;
case "Assert":
break;
default:
throw new KeyWordNotFoundException(row.getCell(0).getStringCellValue());
}
}
} catch (Exception e) {
e.printStackTrace();
}finally{
if(book != null)
book = null;
if(xlStream != null){
try {
xlStream.close();
} catch (IOException e) {
}finally{
xlStream = null;
}
}
}
}
}