How to make my path relative in selenium apache poi while I input my Excel file? and How to write the test result in excel after performing testing

user3724559
FileInputStream input=new FileInputStream(new File("C:\\Report\\TestCase.xls"));
HSSFWorkbook workbook=new HSSFWorkbook(input);
HSSFSheet sheet=workbook.getSheet("KeywordFramework");
System.out.println("i am in");

How can i make my path a relative path ? Example (..\..\TestCase.xls) It should search the file in system and call it , is the requirement

HSSFWorkbook workbook=new HSSFWorkbook(input);
  ExpectedOP=Cellvalue;
    int LastRow = 1;
        for(int i1=1;i1<5;i1++)
        {
        String sr [] =new String [10];
        sr[i1]=driver.findElement(By.xpath(".//*[@id='stepList']/li["+i1+"]")).getText();
        System.out.println("UserID = "+sr[i1]);
        for (int j1=1;j1<sr.length;j1++)
            {
            if(ExpectedOP.equals(j1))
            {
                System.out.println("compare pass");
                String status="PASS";
                Row row1 = sheet.getRow(LastRow);

                Cell cell2 = row1.createCell(18);
                cell2.setCellValue(status);
                System.out.println(status);

                input.close();
                FileOutputStream outFile =new FileOutputStream(new File("TestCase.xls"));
                workbook.write(outFile);
            }
            else
            {
            System.err.println("compare fail");
            String status = "FAIL";
            Row row1 = sheet.getRow(LastRow);

            Cell cell2 = row1.createCell(18);
            cell2.setCellValue(status);
            System.out.println(status);

            input.close();
            FileOutputStream outFile =new FileOutputStream(new File("TestCase.xls"));
            workbook.write(outFile);
            }
            }
        }

This is my code to compare value from website and excel and here am telling IDE to place the pass/fail result in cell number 18 , which i want to make dynamic and also in "i1<5" "5" should be removed and made dynamic which number of cell counts Thank you

Helping Hands

Can you try like :

 FileInputStream input=new FileInputStream(new File("TestCase.xls"));

In your code? I think it should work.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How can I find a specific data, such as a Date in my Excel file, then write time on the column next to it using VB 6.0?

分類Dev

How do I make the directories in a zip file relative to the target directory instead of my working directory

分類Dev

Apache POI jar is not able to write a special character in excel file

分類Dev

How to auto adjust the column in excel in apache POI

分類Dev

how can I write unit test to my meteor methods?

分類Dev

How to Copy and paste my data in the selected file when I use EXCEL VBA

分類Dev

Python selenium using openpyxl to write result to excel file but there is only case is written to excel file

分類Dev

How do I make my program able to handle other symbols input by users? while/try-catch? (java)

分類Dev

In Unix how would I copy /etc/passwd using relative path to a directory under my home directory?

分類Dev

Writing to an excel using Apache POI corrupts the excel file

分類Dev

How to write a Matlab-struct to an Excel file?

分類Dev

How should I write my connection string?

分類Dev

PHPExcel - No content in my excel file

分類Dev

how do i make my code shorter

分類Dev

How do I keep my input fields on one line while centering the DIV that contains them?

分類Dev

In JavaFx how can i make my ComboBox editable after i add an Action to the ComboBox object

分類Dev

How can I make a script autostart after I log into my computer on Ubuntu Mate 15.10?

分類Dev

How do i make my logo fit in my nav bar?

分類Dev

Write to excel using Apache POI. FileNotFoundException:(The requested operation cannot be performed on a file with a user-mapped section open)

分類Dev

how to run my selenium test methods in parallel using testng

分類Dev

Cannot read from Excel file using apache poi

分類Dev

How do I reset the input field after clicking to send my message

分類Dev

SprikeKit physics - How can i make my character stand up after falling down?

分類Dev

Can I provide a relative deps path in my bazel target?

分類Dev

How can I tell if my columns are R1C1 reference style with excel vba?

分類Dev

How do I serve my index.html file while using PHP Slim REST Api?

分類Dev

How do I get this result with excel, notepad++ or something else?

分類Dev

How to open an excel file with write protection using C#

分類Dev

How is "No such file or directory" getting added to my PATH variable?

Related 関連記事

  1. 1

    How can I find a specific data, such as a Date in my Excel file, then write time on the column next to it using VB 6.0?

  2. 2

    How do I make the directories in a zip file relative to the target directory instead of my working directory

  3. 3

    Apache POI jar is not able to write a special character in excel file

  4. 4

    How to auto adjust the column in excel in apache POI

  5. 5

    how can I write unit test to my meteor methods?

  6. 6

    How to Copy and paste my data in the selected file when I use EXCEL VBA

  7. 7

    Python selenium using openpyxl to write result to excel file but there is only case is written to excel file

  8. 8

    How do I make my program able to handle other symbols input by users? while/try-catch? (java)

  9. 9

    In Unix how would I copy /etc/passwd using relative path to a directory under my home directory?

  10. 10

    Writing to an excel using Apache POI corrupts the excel file

  11. 11

    How to write a Matlab-struct to an Excel file?

  12. 12

    How should I write my connection string?

  13. 13

    PHPExcel - No content in my excel file

  14. 14

    how do i make my code shorter

  15. 15

    How do I keep my input fields on one line while centering the DIV that contains them?

  16. 16

    In JavaFx how can i make my ComboBox editable after i add an Action to the ComboBox object

  17. 17

    How can I make a script autostart after I log into my computer on Ubuntu Mate 15.10?

  18. 18

    How do i make my logo fit in my nav bar?

  19. 19

    Write to excel using Apache POI. FileNotFoundException:(The requested operation cannot be performed on a file with a user-mapped section open)

  20. 20

    how to run my selenium test methods in parallel using testng

  21. 21

    Cannot read from Excel file using apache poi

  22. 22

    How do I reset the input field after clicking to send my message

  23. 23

    SprikeKit physics - How can i make my character stand up after falling down?

  24. 24

    Can I provide a relative deps path in my bazel target?

  25. 25

    How can I tell if my columns are R1C1 reference style with excel vba?

  26. 26

    How do I serve my index.html file while using PHP Slim REST Api?

  27. 27

    How do I get this result with excel, notepad++ or something else?

  28. 28

    How to open an excel file with write protection using C#

  29. 29

    How is "No such file or directory" getting added to my PATH variable?

ホットタグ

アーカイブ