Skip to content

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

Open

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();

}}

Activity

  1. Namrata-m13 commented on Feb 1, 2021

    @Namrata-m13

    @Ojasadi From the shared code snippet, I see that you are running the tests on your local Chrome browser and not on BrowserStack. Do confirm if you are running the tests on BrowserStack and facing the mentioned behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions