screenshot in robotium

public class NewRobotiumTest extends ActivityInstrumentationTestCase2 {............ // actual testcase public void testRecorded() throws Exception { solo.waitForActivity("com.botskool.DialogBox.DialogBox", ACTIVITY_WAIT_MILLIS); solo.clickOnButton("Show Alert"); solo.clickOnButton("Ok"); solo.clickOnButton("Show Yes/No"); takeScreenShot(solo.getViews().get(0), "testRecorded_1316975601089"); solo.sleep(2000); solo.clickOnButton("Yes"); solo.clickOnButton("Show List"); solo.clickOnScreen(118f, 563f); } /** * I have added this to the android-manifest.xml file * * * */ public void takeScreenShot(final View view, final String name) throws Exception { getActivity().runOnUiThread(new Runnable() { @Override public void run() { view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap b = view.getDrawingCache(); FileOutputStream fos = null; try { final String path = Environment.getExternalStorageDirectory()+ "/test-screenshots/"; File dir = new File("/mnt/sdcard/test-screenshots"); if(!dir.mkdirs()){ System.out.println("Creaet sd card failed"); } if (!dir.exists()) { System.out.println(path); dir.mkdirs(); } fos = new FileOutputStream(path + name + ".jpg"); if (fos != null) { b.compress(Bitmap.CompressFormat.JPEG, 90, fos); fos.close(); } } catch (IOException e) { } } }); }}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值