0

I have extended Selenium using the Java WebDriver library and the TestNG framework. When running test scripts, I notice an inordinate amount of time for the test to start execution, when the test takes in input parameters from an Excel file (using the @DataProvider annotation).

The delay can amount to about 10 min, which makes it time consuming to run and debug. Is there a reason for this significant delay?

Mosam Mehta
  • 1,658
  • 6
  • 25
  • 34
rs79
  • 2,311
  • 2
  • 33
  • 39
  • Please read the guide [How do I ask a good question](http://stackoverflow.com/help/how-to-ask), especially the part on Minimal, Complete, and Verifiable example (MCVE). This will help you solve problems for yourself. If you do this and are still stuck you can come back and post your MCVE, what you tried, and what the results were so we can better help you. – JeffC Sep 17 '15 at 16:53

2 Answers2

0

Yes could be because of the way you are reading from excel (greedy data provider) and depends on how big your excel file is. There is something called lazy data provider. Found an example of one here . Posting the code from the link.

For better understanding need to see your code.

public class LazyDataProviderExample {
    @Test(dataProvider = "data-source")
    public void myTestMethod(String info) {
        Reporter.log("Data provided was :" + info, true);
    }

    @DataProvider(name = "data-source")
    public Iterator<Object[]> dataOneByOne() {
        return new MyData();

    }

    private static class MyData implements Iterator<Object[]> {
        private String[] data = new String[] { "Java", "TestNG", "JUnit" };
        private int index = 0;

        @Override
        public boolean hasNext() {
            return (index <= (data.length - 1));
        }

        @Override
        public Object[] next() {
            return new Object[] { data[index++] };
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException("Removal of items is not supported");
        }
    }

}
Shamik
  • 1,591
  • 2
  • 16
  • 36
0

For some reason, this issue was resolved by rebuilding my custom Firefox profile - it may have gotten corrupt.

Just posting this as an answer for reference, in case any one is bogged down by this issue.

rs79
  • 2,311
  • 2
  • 33
  • 39