-1

In Selenium Apachi POI - how can I get cell content and change sheet?

Scenario #

  1. I have first sheet as "Test" which has 2 Test Scenario in 2 column as

    TestScn ---------------- RunMod

    Login--------------------- NO

    Checkemail -------------Yes

  2. Now I have 2 more sheets named after "TestScn" (Login & Checkemail)

  3. Can please provide Webdriver code to navigate to the sheet if RunMod is "Yes" & extract data from that sheet & come back to the first ("Test") sheet

4

2 回答 2

0

以下是一段代码。

int RunModeIndex = 1;
int SheetIndex = 0;
Iterator <Row> testRowItr=wb.getSheet("test").iterator();
while(testRowItr.hasNext()){
    System.out.println(testRowItr.next().getCell(RunModeIndex).toString());
    if(testRowItr.next().getCell(RunModeIndex).toString().equalsIgnoreCase("Yes")){
        Sheet sheetToExecute = wb.getSheet(testRowItr.next().getCell(SheetIndex).toString());
        //now sheetToExecute have RunMode = Yes. It is the sheet on which you have to perform execution
        }else{
            //code for the sheet having runMode  = No
    }
}     
于 2013-08-06T07:11:45.200 回答
0

setActiveSheet(...)- 根据文档,这似乎是您的解决方案

另一个简单的解决方案:

//Get first sheet from the workbook
HSSFSheet sheet = workbook.getSheetAt(0);
于 2013-08-06T02:01:17.140 回答