screenshot in robotium
2014-03-30 15:12
399 查看
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) { } } }); }}
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) { } } }); }}
相关文章推荐
- How to screenshot in Linux
- Taking a screenshot of current Activity in Android
- How To Reset Win+PrtScr Screenshot Counter in Windows 10 | 8.1
- Simple and easiest way to make a screen shot in .net 2.0
- Taking a screenshot in XNA 4.0
- Take webpage screenshot from command line in Ubuntu Linux | Binary Tides
- Appium - Capture Screenshot On Failure Or Pass In Android Test Automation
- Commands to take a ScreenShot in max OS X
- How to take partial screenshot with Selenium WebDriver in python
- [Ubuntu] Four different ways to take a screenshot in Ubuntu
- QT Screenshot Example 看看看
- How to solve: when using tab in gnomeTerminal , the entire screen flash,
- 我的Android进阶之旅------>android中getLocationInWindow 和 getLocationOnScreen的区别
- selenium(java)之屏幕截图操作TakesScreenshot
- 网页截图:注释&批注( Webpage Screenshot)
- Linux 截图工具之 gnome-screenshot
- ABAP - REPORT - How to add user-pushbutton in selection screen
- atx warning, screenshot failed
- android screenshot
- android获得控件在屏幕中的绝对坐标 getLocationInWindow 和 getLocationOnScreen