Note that there are some explanatory texts on larger screens.

plurals
  1. PONull pointer exception on consecutive execution of the test script
    primarykey
    data
    text
    <p>I am automating a product using Robotium. In a module I have to validate the data derived.</p> <p>For that I am using this code:</p> <pre><code>class sharefirstlevel { public void A { for(int k=1;k&lt;=4;k+=2) { ExpectedResult = solo.clickInList(k); for (int i = 0; i &lt; ExpectedResult.size(); i++) { Actualvalues[i] += ExpectedResult.get(i).getText().toString() + " "; solo.scrollListToLine(0, k); ExpectedResult=solo.clickInList(1); Actualvalues[i] += ExpectedResult.get(i).getText().toString() + " "; ExpectedResult = solo.clickInList(2); Actualvalues[i] += ExpectedResult.get(i).getText().toString() + " "; Log.d("xyz","Values of the Strings are"+Actualvalues[i].toString()); } } } } </code></pre> <p>Its extracting the values selected to an array.</p> <p>Now when its derived, to validate I am using this code:</p> <pre><code>class sharedLevel { public void B { for(int i=0; i &lt;= sharefirstlevel.Actualvalues.length; i++) { Log.d("xyz","Values are:"+sharefirstlevel.Actualvalues[i]); actual=solo.searchText(sharefirstlevel.Actualvalues[i]); assertEquals(expected, actual); Log.d("xyz","Values are:"+sharefirstlevel.Actualvalues[i]); } } } </code></pre> <p>The values are getting extracted to the array and when printed, the proper values are getting inseted to the array and are even getting passed to another class.</p> <p>But the execution of the junit test case will be successful only for 1 or 2 times. But from then i am getting a null pointer exception. Please help me. Am at a fix!!</p> <p>The first value while getting inserted to the ArrayList itself is null. Here is the Code:</p> <pre><code> for(int k=1;k&lt;=4;k+=2) { ExpectedResult = solo.clickInList(k); for (int i = 0; i &lt; ExpectedResult.size(); i++) { Actualvalues[i] += ExpectedResult.get(i).getText().toString() + " "; solo.scrollListToLine(0, k); ExpectedResult=solo.clickInList(1); Actualvalues[i] += ExpectedResult.get(i).getText().toString() + " "; ExpectedResult = solo.clickInList(2); Actualvalues[i] += ExpectedResult.get(i).getText().toString() + " "; Log.d(" ","Values of the Strings are"+Actualvalues[i].toString()); } } </code></pre> <p>The value getting inserted at the first line within the for loop itself is null. Hence the problem.</p> <p>But I am not getting, why null value is being inserted at 0th position. Please help me out for solutions.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload