[英]I am using TestNg for data driven framework,but data is not fetching from excel
public class FlightVia {
FirefoxDriver driver;
Sheet s;
@Test
public void flight(String From) throws BiffException, IOException {
driver.findElement(By.id("onewayDiv")).click();
//FileInputStream fis=new FileInputStream("C:/Users/Ravi/Desktop/kdf.xls");
Workbook wb= Workbook.getWorkbook(new File("C:/Users/Ravi/Desktop/kdf.xls"));
s=wb.getSheet("Sheet1");
String fromlist=s.getCell(2, 1).getContents();
// WebElement fromdata= driver.findElement(By.name("sourceA"));
Select fromdata=new Select(driver.findElement(By.name("sourceA")));
fromdata.selectByVisibleText(fromlist);
}
@BeforeTest
public void beforeTest() throws InterruptedException {
driver=new FirefoxDriver();
driver.get("http://in.via.com/");
driver.manage().window().maximize();
Thread.sleep(1000);
driver.findElement(By.name("op")).click();
}
@AfterTest
public void afterTest() {
driver.close();
}
}
當我運行這個 TestNg 時,我得到“跳過:飛行org.testng.TestNGException
:飛行方法需要 1 個參數,但在 @Test 注釋中提供了 0。” 錯誤
在 excel 表中,我將數據作為 From To
孟買 德里
金奈海得拉巴
您需要為飛行方法中的參數From
提供值。 您可以使用下面提到的任何一種方法:
請查看 TestNG 文檔。
希望能幫助到你!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.