-
Notifications
You must be signed in to change notification settings - Fork 441
Description
package automationFramework;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class ReadWriteExcel {
WebDriver driver;
WebDriverWait wait;
HSSFWorkbook workbook;
HSSFSheet sheet;
HSSFCell cell;
@BeforeTest
public void TestSetup() {
//Set the path of the Firefox Driver
System.setProperty("webdriver.gecko.driver", "E:\\Shilpa\\Selenium\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
//Enter URL
driver.get("http://www.linkedin.com/");
driver.manage().window().maximize();
wait = new WebDriverWait(driver, 30);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void ReadData(int it) throws IOException {
//Import Excel sheet
File src = new File("E:\\Shilpa\\Selenium\\TestData.xlsx");
//Load the file
FileInputStream finput = new FileInputStream(src);
//Load the Wrokbook
workbook = new HSSFWorkbook(finput);
//Load the sheet in which data is stored
sheet = workbook.getSheetAt(0);
for(int i=1; i⁢=sheet.getLastRowNum(); int i; i++)
{
//Import Data from Email
cell = sheet.getRow(i).getCell(1);
cell.setCellType(Cell.CELL_TYPE_STRING);
driver.findElement(By.name("session_key")).sendKeys(cell.getStringCellValue());
//Import Data for Password
cell = sheet.getRow(i).getCell(2);
cell.setCellType(Cell.CELL_TYPE_STRING);
driver.findElement(By.name("session_password")).sendKeys("");
}
}
}
...................................
Error appears:
1565175984288 Marionette INFO Listening on port 57568
1565175984622 Marionette WARN TLS certificate errors will be ignored for this session
Aug 07, 2019 4:36:24 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[Parent 69828, Gecko_IOThread] WARNING: pipe error: 109: file z:/task_1563383129/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341