Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Ojasadi opened this issue Jan 25, 2021 · 2 comments
Open

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

Ojasadi opened this issue Jan 25, 2021 · 2 comments

Comments

@Ojasadi
Copy link

Ojasadi commented Jan 25, 2021

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("[email protected]");
	 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();

}}

@Namrata-m13
Copy link

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@Namrata-m13 @Ojasadi and others