Reputation: 11
I'm trying to write a tests case that takes a screenshot of the screen, and them loads this screenshot for image processing. So far I found the following method
solo.takeScreenshot()
The takeScreenshot() method saves the picture in “/sdcard/Robotium-Screenshots/” folder on device.
Is there any method I could use to access the file saved in this folder?
Thanks!
Upvotes: 1
Views: 1767
Reputation: 928
You can tell robotium what file name to use for the screenshot. Robotium will save the file asynchronously so you need to wait for the file to appear using it.
solo.takeScreenshot("ScreenshotFile");
final File file = new File(Environment.getExternalStorageDirectory() + "/Robotium-Screenshots/", "ScreenshotFile" + ".jpg");
final int TIMEOUT = 5000;
assertTrue(solo.waitForCondition(new Condition() {
@Override
public boolean isSatisfied() {
return file.exists();
}
}, TIMEOUT));
HERE IS WHERE YOU CAN DO WHATEVER YOU WANT WITH file
Of course in subsequent runs the file will exist before you run the test. You either need to clean up the file or generate a new file name for each test run.
Upvotes: 1