How to take a screenshot when hovering a mouse over an SVG?

4,171 views
Skip to first unread message

Vardhan

unread,
Dec 13, 2013, 6:57:17 AM12/13/13
to webd...@googlegroups.com
Hi all,
 
Whenever I am hovering over an SVG element, one tooltip comes which has got some value.
 
I want to take a screenshot at the time when the tooltip comes.
 
But whenever i take screenshot using Selenium, the tooltip is always missing.
 
I want some help on this.
 
 
Regards,
Vardhan
 
PS: I am using Actions class to hover over the SVG element.

darrell

unread,
Dec 14, 2013, 7:23:48 AM12/14/13
to webd...@googlegroups.com
Can you do a screen capture when testing manually? That is, float the mouse over the SVG, making the tooltip appear then try pressing PrtSc in order to capture the screen to the clipboard. Go to mspaint.exe and paste what was captured. Is the tooltip there? If it is not then you might not be able to do a screen capture without some special capture software. If there is a tooltip in the screen capture then you might have to rely on something built into your programming language. For example, you can use the Java Robot class. Have a look at http://darrellgrainger.blogspot.ca/2011/02/generating-screen-capture-on-exception.html and use the createScreenCaptureJPEG and getScreenAsBufferedImage methods. This will not work for RemoteWebDriver.

Vardhan

unread,
Dec 16, 2013, 1:06:31 AM12/16/13
to webd...@googlegroups.com
Hi Darrell,
 
Thank you for your response.
 
But one thing I want to ask is when using the robot class of java, it captures whatever is active on the current window.
But if I go on and minimize my web browser, it will capture my current desktop image.
 
So one question popped up in my mind is:
 
Q: Can't we make two instances of a single web browser, one for hovering and other for taking the screenshot?
 
Please correct me if I am wrong because I have just started working on selenium webdriver.
 
Regards,
Vardhan

Chris Merrill

unread,
Dec 16, 2013, 10:08:56 AM12/16/13
to webd...@googlegroups.com
On 12/16/2013 1:06 AM, Vardhan wrote:
> So one question popped up in my mind is:
>
> Q: Can't we make two instances of a single web browser, one for hovering and other for taking the
> screenshot?

You can, but it won't help. The screenshot that WebDriver gets from the browser is of the rendered
DOM. It doesn't include other UI decorations, such as the window, toolbar, menus, etc. It's
possible the tooltip is implemented by the browser as a separate independent window, much like a
javascript dialog, which also does not appear in the screenshots. It is also possible that this
result will be different in another browser, since it could implement tooltip rendering differently.




--
------------------------------------------------------------------------ -
Chris Merrill | Web Performance, Inc.
ch...@webperformance.com | http://webperformance.com
919-433-1762 | 919-845-7601

Web Performance: Website Load Testing Software & Services
------------------------------------------------------------------------ -

Vardhan

unread,
Dec 16, 2013, 11:44:10 PM12/16/13
to webd...@googlegroups.com
Hello Chris,
 
thank you for the response.
Just want to tell you that somewhat I had managed to take the screenshot of the tooltip and succeeded in answering my own question.
Scenario is working fine for both of my browsers, chrome and firefox.
 
But one thing I want to ask you is;
 
Q: Can we perform operations on the SVG's.?
 
since my application is a reporting application, I am encountering a lot of SVG's and unable to perform operations on them.
 
Please respond.
 
Regards,
Vardhan.

Juluru Karthik

unread,
Feb 27, 2017, 5:58:48 PM2/27/17
to webdriver, vardha...@gmail.com

Hi Vardhan,

Can you please tell me how did you capture the tooltip through screen shot. I have tried in many ways and failed.

Regards,
Karthik Juluru
Reply all
Reply to author
Forward
0 new messages