DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device", "android");
// Take the Screen shot and store it in a file
org.openqa.selenium.WebDriver augmentedDriver = new Augmenter().augment(webDriver);
File screenshot = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
// the name of the file
String filename = "screenshot.png";
FileUtils.copyFile(screenshot, new File(filename));
Using the Java web driver, I was getting a ClassCastException as someone reported on google groups (https://groups.google.com/forum/#!searchin/appium-discuss/screenshot/appium-discuss/A6kAET0C7nc/_I7rszrh8YkJ) when augmenting the driver to be able to take screenshots. I dug a little bit and found that my remote web driver was not being augmented with the TakesScreenshot interface, and then I noticed that the capability for Android (app/android.js) is set totakesScreenshots: true, while the capability constant istakesScreenshot(no 's' at the end).
So I went ahead and changed it locally to see if I could make it work. I ended up with a different error. Now it augments my driver, but I get the following error:org.openqa.selenium.remote.SessionNotFoundException: Session ID is nullHas anyone ever got screenshots working with webdriver for Java and Android?
--
http://appium.io
---
You received this message because you are subscribed to a topic in the Google Groups "Appium-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/appium-discuss/A6kAET0C7nc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to appium-discus...@googlegroups.com.
GET /wd/hub/session/a3c713ca-ce7f-4eb0-8b88-cbbf707abb7f 200 5ms - 288
debug: Appium request initiated at /wd/hub/session/a3c713ca-ce7f-4eb0-8b88-cbbf707abb7f/screenshot
info: Responding to client with success: {"status":0,"value":"","sessionId":"a3c713ca-ce7f-4eb0-8b88-cbbf707abb7f"}
I mean github.com/appium/appium
May 15, 2014 11:50:41 AM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond
May 15, 2014 11:50:41 AM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/d/optout.