Sunteți pe pagina 1din 2

driver.get("https://streakv3.zerodha.

com");

driver.findElement(By.xpath("//input[@id='userid']")).sendKeys("DS1797");

driver.findElement(By.xpath("//input[@id='password']")).sendKeys("GuruJun@2020");
driver.findElement(By.xpath("//button[@type='submit']")).click();

driver.findElement(By.xpath("//input[@id='pin']")).sendKeys("280920");
driver.findElement(By.xpath("//button[@type='submit']")).click();

driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

Actions actions = new Actions(driver);


WebElement mainMenu =
driver.findElement(By.xpath(".//p[text()='Scanners']"));
actions.moveToElement(mainMenu);

WebElement subMenu = driver.findElement(By.xpath(".//button[text()='My


Scans']"));
actions.moveToElement(subMenu);
actions.click().build().perform();

driver.findElement(By.xpath("(//button[text()=\"Scan now\"])
[1]")).click();

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

int RowSize=driver.findElements(By.xpath("//div[@class='rt-
tbody']/div")).size();

System.out.println("Number of Rows Are::" + RowSize);

File Reports = new


File("C:\\Users\\sakthivel.sampath\\Desktop\\Investing_Trading\\Kite_Streak_Reports
.xlsx");

FileOutputStream OutputStream = new FileOutputStream(Reports);

XSSFWorkbook Streak_Workbook = new XSSFWorkbook();

XSSFSheet Streak_Sheet = Streak_Workbook.createSheet("Streak");

XSSFRow Header_row = Streak_Sheet.createRow(0);

Cell Hl=Header_row.createCell(0);
Hl.setCellType(CellType.STRING);
Hl.setCellValue("INSTRUMENTS");

Cell H2=Header_row.createCell(1);
H2.setCellType(CellType.STRING);
H2.setCellValue("SECTORS");

Cell H3=Header_row.createCell(2);
H3.setCellType(CellType.NUMERIC);
H3.setCellValue("LTP");
Cell H4=Header_row.createCell(3);
H4.setCellType(CellType.NUMERIC);
H4.setCellValue("CHANGE %");

Cell H5=Header_row.createCell(4);
H5.setCellType(CellType.NUMERIC);
H5.setCellValue("VOLUMES");

for (int i1=1;i1<=RowSize;i1++)


//for (int i1=1;i1<=5;i1++)
{
String[] arr2;
String aaa,bbb,ccc,ddd,eee;

aaa = (String) driver.findElement(By.xpath("//div[@class='rt-


tbody']/div[@class='rt-tr-group']["+i1+"]/div/div[1]/div")).getText();
bbb = (String) driver.findElement(By.xpath("//div[@class='rt-
tbody']/div[@class='rt-tr-group']["+i1+"]//div[@class='rt-td'][2]/p")).getText();
ccc = (String) driver.findElement(By.xpath("//div[@class='rt-
tbody']/div[@class='rt-tr-group']["+i1+"]//div[@class='rt-td'][3]/p")).getText();
ddd = (String) driver.findElement(By.xpath("//div[@class='rt-
tbody']/div[@class='rt-tr-group']["+i1+"]//div[@class='rt-td'][4]/p")).getText();
eee = (String) driver.findElement(By.xpath("//div[@class='rt-
tbody']/div[@class='rt-tr-group']["+i1+"]//div[@class='rt-td'][5]/p")).getText();

XSSFRow row = Streak_Sheet.createRow(i1);

arr2=aaa.split("\n");

Cell cl=row.createCell(0);
cl.setCellType(CellType.STRING);
cl.setCellValue(arr2[0]);

Cell c2=row.createCell(1);
c2.setCellType(CellType.STRING);
c2.setCellValue(bbb);

Cell c3=row.createCell(2);
c3.setCellType(CellType.NUMERIC);
c3.setCellValue(ccc);

Cell c4=row.createCell(3);
c4.setCellType(CellType.NUMERIC);
c4.setCellValue(ddd);

Cell c5=row.createCell(4);
c5.setCellType(CellType.NUMERIC);
c5.setCellValue(eee);

Streak_Workbook.write(OutputStream);
Streak_Workbook.close();
driver.close();
driver.quit();

S-ar putea să vă placă și