Skip to content

I am not able to get data from Excel to testng class #24

@Ojasadi

Description

@Ojasadi

public class Readandwrite {

public static void main(String[] args) throws IOException {	
	
	
      Workbook wb = new XSSFWorkbook();
	 FileOutputStream f = new FileOutputStream("C:\\Users\\Desktop\\Selenium\\FileHandling\\MyExcelSheet.xlsx");
	 Sheet s = wb.createSheet("MySheet");
	 s.createRow(0).createCell(0).setCellValue("abc@facebook.com");
	 s.getRow(0).createCell(1).setCellValue("abc123");
	 wb.write(f);
	
	

//public static void read() throws IOException {

	 File S = new File("C:\\Users\\Desktop\\Selenium\\FileHandling\\MyExcelSheet.xlsx");
	 FileInputStream input = new FileInputStream(S);
	 XSSFWorkbook wb1 = new XSSFWorkbook(input);
	 XSSFSheet Sh = wb1.getSheet("MySheet");
	
	 
}}

public class ReadandWrite2 extends Readandwrite {
ChromeDriver cd;

//@parameters ({"UserName","pass"})
@BeforeTest
public void ReadandWriteExcel() {

System.setProperty("webdriver.chrome.driver","C:\\Users\Desktop\\Selenium\\chromedriver_win32\\chromedriver.exe");
 cd=new ChromeDriver();
 cd.get("https://www.facebook.com/login.php");	

}

@test
public void usernameandpassword() {
WebElement UserName=cd.findElement(By.id("email"));
WebElement pass= cd.findElement(By.id("pass"));
UserName.sendKeys(Sh.getRow(1).getCell(0).getStringCellValue());//Error
pass.sendKeys(Sh.getRow(1).getCell(1).getStringCellValue());//Error
cd.findElement(By.xpath("//*[@id="loginbutton"]")).click();

}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions