Not able to take screenshot in iphone webdriver

513 views
Skip to first unread message

vishal

unread,
Aug 31, 2011, 6:24:40 PM8/31/11
to webdriver
Hi

I tried using following code while writing tests with iPhone webdriver
File scrFile =
((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

This resulted in an error java.lang.ClassCastException:
org.openqa.selenium.remote.RemoteWebDriver cannot be cast to
org.openqa.selenium.TakesScreenshot
com.minime.IphoneTest.crickInfo(IphoneTest.java:184)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

and if use File scrFile =
((Screenshot)driver).getScreenshotAs(OutputType.FILE); then my code
doesnt compile as it doesnt identify Screenshot interface.

Any pointers what i might be doing wrong.

Thanks Vishal

vishal

unread,
Aug 31, 2011, 6:26:57 PM8/31/11
to webdriver
just to add to it..this is how i am setting up my webdriver.

DesiredCapabilities capability = new DesiredCapabilities();
capability.setPlatform(Platform.ANY);
driver = new RemoteWebDriver(new URL(webdriverAddress),capability);

Krishnan Mahadevan

unread,
Aug 31, 2011, 10:11:14 PM8/31/11
to webd...@googlegroups.com
Vishal,
RemoteWebDriver doesn't implement TakeScreenshot interface, which explains why you get the classcast exception.
You would have to extend RemoteWebDriver and have your class implement TakeScreenshot interface and then work with it instead.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.


Daniel Wagner-Hall

unread,
Sep 1, 2011, 12:51:27 AM9/1/11
to webd...@googlegroups.com
RemoteWebDriver doesn't implement TakesScreenshot.

You can augment the RemoteWebDriver to give it all of the interfaces
its proxied driver implements:

WebDriver augmentedDriver = new Augmenter().augment(driver);

((TakesScreenshot)augmentedDriver).getScreenshotAs(...); //should now work

vishal

unread,
Sep 1, 2011, 8:37:34 PM9/1/11
to webdriver
thanks it worked...thanks again
Reply all
Reply to author
Forward
0 new messages