Android Studio 环境Robotium网页相关测试异常java.lang.NullPointerException: lock == null

 Assert.assertTrue("OpenWebUrlError", solo.waitForWebElement(By.textContent("找不到网页")));

java.lang.NullPointerException: lock == null
at java.io.Reader.<init>(Reader.java:64)
at java.io.InputStreamReader.<init>(InputStreamReader.java:122)
at java.io.InputStreamReader.<init>(InputStreamReader.java:59)
at com.robotium.solo.WebUtils.getJavaScriptAsString(WebUtils.java:354)
at com.robotium.solo.WebUtils.prepareForStartOfJavascriptExecution(WebUtils.java:162)
at com.robotium.solo.WebUtils.executeJavaScriptFunction(WebUtils.java:276)
at com.robotium.solo.WebUtils.executeJavaScript(WebUtils.java:238)
at com.robotium.solo.WebUtils.getWebElements(WebUtils.java:111)
at com.robotium.solo.Searcher.searchForWebElement(Searcher.java:238)
at com.robotium.solo.Waiter.waitForWebElement(Waiter.java:498)
at com.robotium.solo.Solo.waitForWebElement(Solo.java:672)
AndroidStudio直接调用Robotium源码时,测试网页相关所有case都抛出以上异常,
定位

BufferedReader input =  new BufferedReader(new InputStreamReader(fis));

该语句抛出null异常

InputStream fis = getClass().getResourceAsStream("RobotiumWeb.js");


执行发现这个js文件似乎读取失败,修改读取路径到androidTest下也抛出同样的异常,由于AS新的三部分架构可能改变了测试的框架导致,getResourceAsStream读取文件失败


暂时解决办法把这个js文件扔到sdcard里了


InputStream fis = new FileInputStream(new File("/sdcard/RobotiumWeb.js"));


测试执行通过。













  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值