-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest5.java
More file actions
56 lines (45 loc) · 1.5 KB
/
Test5.java
File metadata and controls
56 lines (45 loc) · 1.5 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
package dataDriven;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
public class Test5 {
public FileInputStream fis;
public static Workbook wb;
public static Sheet sh;
public static Row row;
public static Cell cell;
public WebDriver driver;
public static FileOutputStream fos;
public String readDatafromExcel() throws EncryptedDocumentException, IOException {
fis = new FileInputStream("./data.xlsx");
wb = WorkbookFactory.create(fis);
sh = wb.getSheet("Sheet1");
row = sh.getRow(1);
cell = row.getCell(4);
return cell.getStringCellValue();
}
public String getDataFromApplication() {
WebDriverManager.chromedriver().setup();
driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.google.com/");
return driver.getTitle();
}
public static void writeDataToExcel(int rownum,int cellnum,String data) throws IOException {
row=sh.getRow(rownum);
cell=row.getCell(cellnum);
cell.setCellValue(data);
fos=new FileOutputStream("./data.xlsx");
wb.write(fos);
}
}