简体   繁体   English

我正在将 TestNg 用于数据驱动框架,但未从 excel 中获取数据

[英]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(); 
  }
  }

when i am running this TestNg i am getting "SKIPPED: flight org.testng.TestNGException : Method flight requires 1 parameters but 0 were supplied in the @Test annotation."当我运行这个 TestNg 时,我得到“跳过:飞行org.testng.TestNGException :飞行方法需要 1 个参数,但在 @Test 注释中提供了 0。” error错误

in excel sheet i am giving data as From To在 excel 表中,我将数据作为 From To
Mumbai Delhi孟买 德里
Chennai Hyderabad金奈海得拉巴

You need to provide the value for the parameter From in the flight method.您需要为飞行方法中的参数From提供值。 You can use any of the method mentioned below:您可以使用下面提到的任何一种方法:

Please check the TestNG document.请查看 TestNG 文档。

Hope it helps!希望能帮助到你!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 数据驱动的TestNG从Excel传入参数 - Data Driven TestNG Passing in parameters from excel 我正在使用 Selenium 尝试数据驱动框架。 我有一个示例程序可以从 Excel 表中获取 url 并打开浏览器 - I am Trying Data Driven Framework with Selenium. Where i have a sample program to get url from excel sheet and make browser open 使用带有TestNG框架的Apache POI将数据写入excel - Write data to excel using Apache POI with TestNG framework Web驱动程序和数据驱动框架中的testng的并行执行测试是否可靠 - Is parallel execution of test is reliable in Web driver and testng in data driven framework 如何构建数据驱动的 Selenium WebDriver + Java + TestNG 框架 - How to Build a Data Driven Selenium WebDriver + Java + TestNG Framework 从Excel提取数据的问题(使用Java) - Issue with fetching data from excel (Using Java) 使用POI和TestNG ..code的Selenium中的数据驱动测试出错 - Data driven testing in Selenium using POI and TestNG ..code getting error 如何使用 TestNG 解决数据驱动测试中的方法匹配器异常? - how to resolve methodmatcher exception in data driven testing using TestNG? TestNG中的DataProvider使用Java WebDriver从Excel传递数据 - DataProvider in TestNG to pass data from Excel using Java WebDriver 如何从网站获取数据并在 excel Page object model 中打印 - How to fetch data from website and print in excel Page object model, Data driven and page factory this is hybrid framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM