Qaf: Implementing Excel Test Factory

Created on 29 May 2018  ·  9Comments  ·  Source: qmetry/qaf

QAF Version

Note: only the latest version is supported

Steps To Reproduce

1. Create a xls file under scenario
2.In the config file use the ExcelTestFactory class
3.Execute

Expected behavior

It should be executed successfully

Actual behavior

jxl.read.biff.BiffException: Unable to recognize OLE stream
at jxl.read.biff.CompoundFile.(CompoundFile.java:116)
at jxl.read.biff.File.(File.java:127)
at jxl.Workbook.getWorkbook(Workbook.java:221)
at jxl.Workbook.getWorkbook(Workbook.java:198)
at com.qmetry.qaf.automation.step.client.excel.ExcelScenarioFileParser.parseFile(ExcelScenarioFileParser.java:46)
at com.qmetry.qaf.automation.step.client.excel.ExcelScenarioFileParser.parse(ExcelScenarioFileParser.java:60)
at com.qmetry.qaf.automation.step.client.ScenarioFactory.process(ScenarioFactory.java:110)
at com.qmetry.qaf.automation.step.client.ScenarioFactory.getTestsFromFile(ScenarioFactory.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.FactoryMethod.invoke(FactoryMethod.java:90)
at org.testng.internal.TestNGClassFinder.(TestNGClassFinder.java:150)
at org.testng.TestRunner.initMethods(TestRunner.java:451)
at org.testng.TestRunner.init(TestRunner.java:270)
at org.testng.TestRunner.init(TestRunner.java:240)
at org.testng.TestRunner.(TestRunner.java:192)
at org.testng.remote.support.RemoteTestNG6_9_10$1.newTestRunner(RemoteTestNG6_9_10.java:29)
at org.testng.remote.support.RemoteTestNG6_9_10$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_9_10.java:65)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:594)
at org.testng.SuiteRunner.init(SuiteRunner.java:168)
at org.testng.SuiteRunner.(SuiteRunner.java:117)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1319)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1306)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1160)
at org.testng.TestNG.run(TestNG.java:1064)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Is the issue reproducible on runner?

  • [x ] Eclipse

Test case sample

Config File:



</classes>

help wanted kwd-excel

All 9 comments

Can you please update config file code and provide excel file which you are using?

Config file:

<test name="Test" enabled="true">
<parameter name="scenario.file.loc" value="./scenarios/Platform_Automation/test.xls"></parameter>
    <classes>
        <class name="com.qmetry.qaf.automation.step.client.excel.ExcelTestFactory" />



    </classes>
</test>

Excel Sheet:

I am not able to attach the excel sheet. But below is the content of the excel sheet and the sheet name is test.xls.

SCENARIO: batchprocessor |   |   |   |   |   |  
-- | -- | -- | -- | -- | -- | --
META-DATA: {"description":"Verify ","groups":[SMOKE","Regression"], "author":"Arun"}
  |   |   |   |   |   |   |   |   |  
  | Given run '${unix.command.ondot-status}' on 'virtual.machine' |   |  
  | Then ondot-status for Active Validation |   |   |   |   |  
END |   |   |   |   |   |   |   |   |  

The format you have defined for excel is a wrong format.
Below is working test and excel file.

<test name="Test" enabled="true">
    <parameter name="scenario.file.loc" value="./scenarios/test.xls"></parameter>
    <classes>
        <class name="com.qmetry.qaf.automation.step.client.excel.ExcelTestFactory" />
    </classes>
</test>

SCENARIO | SearchProduct | {"description":"verify user is able to search product using search textbox","groups":["SMOKE"]}
-- | -- | --
launchApp |   |  
searchForProduct | ["Shirt"] |  
END |   |

Here 1st column should be stepname(not description), and 2nd column is list of arguments.
And step implementation is

@QAFTestStep(description = "I search for product {0}")
public void searchForProduct(String product) {
    //to-do
}

I changed the excel format but still I am getting the same error. Do we have a sample project for this?

Scenario | Test | {"description":"verify user is able to search product using search textbox","groups":["SMOKE"]}
-- | -- | --
run | ["Hello"] |  
END |   |  

Also, What should I do if I want to pass multiple inputs :)

Thanks in advance :)

Looks like your excel is not in proper xls format.

Thanks Amit :) That was correct. I was using corrupted file :) Thanks much.

Also, I use one input in the excel file and my method takes one parameter. But the input which I am giving in the sheet is not getting passed.

Could you please share the step definition for the above excel sheet you shared ? :)

I have updated step implementation in above comment. You can refer that.

Thank you :) It worked :) I actually copy pasted the bdd scenario into the excel sheet :) and it read the data from xml and property file:)

Happy :) Thanks for the help Amit :)

Hi Amit,

I have this scenario. I need to pass JSONArray or JsonObject as an input. I am using ExcelTestFactory.

Below is my sample input:

["nodename",["a","b","c"]]

I want the whole world to be read. QAF is not able to read everything as a whole as I have comma in it.

Can you please tell me how I can address this :)

Thanks much in advance for the help.

Also, I cannot store these values in an external file as the input is coming from external team.

Kindest Regards,
CK

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nandesh7 picture Nandesh7  ·  8Comments

cjayswal picture cjayswal  ·  17Comments

APrem picture APrem  ·  7Comments

Rupak-66 picture Rupak-66  ·  12Comments

raviguptasmarsh picture raviguptasmarsh  ·  8Comments