Ниже приведен код < /p>
@RunWith(AndroidJUnit4.class)
public class ScreenshotJavaTest {
// a handy JUnit rule that stores the method name
@Rule
public TestName nameRule = new TestName();
@Rule
public ActivityScenarioRule activityScenarioRule =
new ActivityScenarioRule(MainActivity.class);
/**
* Captures and saves an image of the entire {@link MainActivity} contents.
*/
@Test
public void saveActivityBitmap() throws IOException {
writeToTestStorage(captureToBitmap(onView(isRoot())), getClass().getSimpleName() + "_" + nameRule.getMethodName());
}
/**
* Captures and saves an image of the 'Hello world' view.
*/
@Test
public void saveViewBitmap() throws IOException {
writeToTestStorage(captureToBitmap(onView(withText("Hello World!"))), getClass().getSimpleName() + "_" + nameRule.getMethodName());
}
/**
* Captures and saves an image of the entire device screen to storage.
*/
@Test
public void saveDeviceScreenBitmap() throws IOException {
writeToTestStorage(takeScreenshot(), getClass().getSimpleName() + "_" + nameRule.getMethodName());
}
}
< /code>
Все тестовые примеры работают, но я не могу найти каких -либо скриншотов в любом месте диспетчера файлов устройства. Итак, как я найду эти скриншоты или есть другие способы достичь, чтобы получить
Эти скриншоты в тестировании автоматизации < /p>
Подробнее здесь: https://stackoverflow.com/questions/745 ... g-expresso