Re: Not Able to Take Screenshot on Safari Using Grid and RemoteWebDriver

213 views
Skip to first unread message

Mike Riley

unread,
Sep 16, 2012, 1:10:45 AM9/16/12
to seleniu...@googlegroups.com
Normally you would augment RemoteWebDriver (which was just recently discussed in a couple of threads), but I seem to recall seeing something to the effect that the Safari driver can't do screen shots yet.

Mike

On Friday, September 14, 2012 3:28:11 PM UTC-7, akki wrote:
Hi, I am trying to get a screenshot from Safari using Grid and RemoteWebDriver. I have tried the following approaches:

1. Using the code below. It works on all browsers except Safari. I also tried returning a BASE64 string but didn't work.
WebDriver augmentedDriver = new Augmenter().augment(driver);
File source = ((TakesScreenshot)augmentedDriver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(source, new File("screenshot.png"));
Exception: org.openqa.selenium.WebDriverException

2. Using WebDriverBackedSelenium. This throws exception.
a.
Selenium sel = new WebDriverBackedSelenium(driver, driver.getCurrentUrl());
sel.captureScreenshot(filename);
Exception: java.lang.UnsupportedOperationException: captureScreenshot

b.Selenium sel = new WebDriverBackedSelenium(driver, driver.getCurrentUrl());
sel.captureScreenshotToString();
Exception: java.lang.UnsupportedOperationException: WebDriver does not implement TakeScreenshot

3. I tried sending the key squence that take screen shots in MAC (command+shift+3) using sendKeys(Keys.chord(Keys.COMMAND, Keys.SHIFT, "3")) but Keys.COMMAND is not considered as modifier key so this also didn't work.

After some research I cam across these two issues below:

I also saw this revision which is suppose to fix the issue but I am not able to figure out how to implement this

I would really appreciate if I could get some help on this. I am using MAC, Safari 5.1.7 and selenium 2.25.

akki

unread,
Sep 16, 2012, 8:57:02 PM9/16/12
to seleniu...@googlegroups.com
Is there any alternative for taking screenshots on Safari? It may involve outside solutions which can be called from within the code. Can be an executable created from other tools which will do the job. There must be something out there. I mean all problems have a solution.

Mike Riley

unread,
Sep 19, 2012, 2:12:03 PM9/19/12
to seleniu...@googlegroups.com
I believe the Robot class can take a shot of the window or the entire desktop, if you add that to your code.

Mike

akki

unread,
Sep 24, 2012, 10:46:03 AM9/24/12
to seleniu...@googlegroups.com
Robot class did the job of taking the screenshot but this cannot be used for a remote machine. If that is locked it will take a screenshot of the locked desktop screen.

Richa Walia

unread,
Sep 24, 2012, 11:23:51 AM9/24/12
to seleniu...@googlegroups.com
u can install caffine so that te remote machine is never locked.

On Mon, Sep 24, 2012 at 3:46 PM, akki <akki...@gmail.com> wrote:
Robot class did the job of taking the screenshot but this cannot be used for a remote machine. If that is locked it will take a screenshot of the locked desktop screen.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/YxDX3WkmYywJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
keep smiling it doesn't cost anything

akki

unread,
Sep 24, 2012, 5:21:19 PM9/24/12
to seleniu...@googlegroups.com
Robot class is taking desktop screen shots of local machine. For this you will always have to have the browser window open that you wanna capture and in a parallel test environment it is impossible. I think its not an alternative to Augmented Driver.
Reply all
Reply to author
Forward
0 new messages