简体   繁体   中英

Robotium - Set screenshot save path doesn't work

I want to save the screenshot to /sdcard/Robotium-Screenshots/testLogin/en/ .

The following code work perfectly fine. It creates a testLogin folder in Robotium-Screenshots and save the screenshot:

String path = "/sdcard/Robotium-Screenshots/testLogin/";
solo.getConfig().screenshotSavePath = "/sdcard/Robotium-Screenshots/";
solo.takeScreenshot("abc");

But when I change the path to:

String path = "/sdcard/Robotium-Screenshots/testLogin/en/";

I cannot find testLogin and en folders and screenshots.

Had the same problem, it doesn't work because the directory does not exist yet. With the following code, I check if the directory exists and create the directory if it does not.

File directory = new File(path);
if (!directory.exists()) {
    directory.mkdirs();
}

After making sure the directory exists, you can take the screenshot. I hope this helped!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM