80,471
社区成员




@RunWith(AndroidJUnit4.class)
public class BySelectorTest {
UiDevice device;
Instrumentation instrumentation;
@Before
public void setUp() throws RemoteException, UiObjectNotFoundException {
//初始化
instrumentation= InstrumentationRegistry.getInstrumentation();
device=UiDevice.getInstance(instrumentation);
}
@Test
public void testByselectorBy() throws UiObjectNotFoundException, RemoteException {
Boolean tmpa = device.takeScreenshot(new File("/mnt/sdcard/DCIM/test2.png"));
System.out.println("截屏返回值:" + tmpa);
}
}
04-13 14:24:13.428 5144-5158/? W/gralloc_ranchu: Gralloc pipe failed
[ 04-13 14:24:13.428 5144: 5158 D/ ]
HostConnection::get() New Host Connection established 0xa0738180, tid 5158
04-13 14:24:13.457 1229-1229/? E/EGL_emulation: tid 1229: eglCreateSyncKHR(1451): error 0x3004 (EGL_BAD_ATTRIBUTE)
04-13 14:24:13.547 5160-5184/? E/UiAutomatorBridge: failed to save screen shot to file
java.io.FileNotFoundException: /data/local/tmp/test2.png (Permission denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
at android.support.test.uiautomator.UiAutomatorBridge.takeScreenshot(UiAutomatorBridge.java:131)
at android.support.test.uiautomator.UiDevice.takeScreenshot(UiDevice.java:1025)
at android.support.test.uiautomator.UiDevice.takeScreenshot(UiDevice.java:1009)
at BySelectorTest.testByselectorBy(BySelectorTest.java:71)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)
04-13 14:24:13.548 5160-5184/? I/System.out: 截屏返回值:false
04-13 14:24:13.549 5160-5184/? I/TestRunner: finished: testByselectorBy(BySelectorTest)
04-13 14:24:13.553 5160-5160/? I/MonitoringInstrumentation: Activities that are still in CREATED to STOPPED: 0
04-13 14:24:13.553 5160-5184/? I/TestRunner: started: useAppContext(com.example.administrator.ui2byselector.ExampleInstrumentedTest)
04-13 14:24:13.554 5160-5160/? I/MonitoringInstrumentation: Activities that are still in CREATED to STOPPED: 0
04-13 14:24:13.555 5160-5184/? I/TestRunner: finished: useAppContext(com.example.administrator.ui2byselector.ExampleInstrumentedTest)
04-13 14:24:13.556 5160-5160/? I/MonitoringInstrumentation: Activities that are still in CREATED to STOPPED: 0
04-13 14:24:13.558 5160-5184/? I/TestRunner: run finished: 2 tests, 0 failed, 0 ignored
04-13 14:24:13.559 5160-5184/? I/MonitoringInstrumentation: waitForActivitiesToComplete() took: 0ms
04-13 14:24:13.560 5160-5160/? I/MonitoringInstrumentation: Activities that are still in CREATED to STOPPED: 0
04-13 14:24:13.560 1489-1503/system_process W/WindowManager: Attempted to remove non-existing token: android.os.Binder@27006d6
04-13 14:24:13.564 1489-1887/system_process I/ActivityManager: Force stopping com.example.administrator.ui2byselector appid=10075 user=0: finished inst
04-13 14:24:13.564 1489-1887/system_process I/ActivityManager: Killing 5160:com.example.administrator.ui2byselector/u0a75 (adj 0): stop com.example.administrator.ui2byselector
04-13 14:24:13.574 5144-5157/? I/art: Starting a blocking GC HeapTrim
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>