Why below code is throwing nullPointer exception in last line (when accessing javaInterface.mValue) This line through NullPointer, so basically it is not being set. even though the javascript is correct and has been verified using FireBug that it returns expected string.
There are few lines above this code chunk but it is irrelevant this problem
DemoJavaScriptInterface javaInterface = new
DemoJavaScriptInterface();
storeView.addJavascriptInterface(javaInterface, "demo");
//String jScript4 = "";
solo.sleep(10000);
//storeView.loadUrl("javascript:var
mV=document.getElementById(\"color-link-box-top
\").getElementsByTagName(\"p\")[0].innerHTML;alert(mV);");
solo.sleep(2000);
storeView.loadUrl("javascript:window.demo.Value(document.getElementById(\"c olor-
link-box-top\").getElementsByTagName(\"p\")[0].innerHTML)");
System.out.println(javaInterface.mValue); //This line
through NullPointer, so basically it is not being set.
//Assert.assert()
}
final class DemoJavaScriptInterface
{
String mValue;
public void Value(String myVal)
{
mValue = myVal;
}
DemoJavaScriptInterface() {
}
}