11

I am using Robot Framework to automate a website. This website uses a Silverlight application to display video.

My Objective: To create a custom keyword in my Robot Framework that takes a web element, the web element being the location of where the Silverlight player is located on the page and taking a screenshot of what is visible. I do not need to interact with the Silverlight application.

Work Done Already: I have already created a custom keyword Capture Screenshot Of Element which takes a web element and returns a screenshot of just that specific element. However, if the element contains a Silverlight application, all I get back is a blank background colour, not the image displayed on the Silverlight application.

Is there a way to specify a web element in a browser and display what is actually seen on screen in that element?

p_cos
  • 185
  • 1
  • 9
  • 1
    Try screencapturing the whole screen/web driver, then use the co-ords of the element to crop it the image – Alastair McCormack Jan 28 '16 at 09:03
  • @AlastairMcCormack When you say screen capturing the whole screen, do you mean using `Capture Page Screenshot` in Robot Framework and then using co-ords to crop the image? If so, this is already what I'm doing. – p_cos Jan 28 '16 at 09:04
  • Call `driver.save_screenshot()` as per http://stackoverflow.com/questions/8900073/webdriver-screenshot. I'm not sure how that translates it Robot Framework :( – Alastair McCormack Jan 28 '16 at 09:08
  • @AlastairMcCormack I am already doing the equivalent to this in Robot Framework. The keyword is `Capture Page Screenshot`. As a comparison, I had already tried the writing a Python Selenium script as mentioned in that link. The results are the same in both cases; the image within the Silverlight application is not displayed. All you get is a screenshot of the background colour. – p_cos Jan 28 '16 at 09:20
  • What browser are you using? Can you open the page using robot framework? If you can, is your video playing automatically properly? – Lefty G Balogh Dec 09 '19 at 11:49
  • You also can try to use any third-party service for taking screenshots. – Serhii Matvienko Jan 12 '20 at 12:41

1 Answers1

0

Though this is a very old question but I came across similar problem before and want to share the details here.

When you take screenshot using selenium library it calls web driver method to translate the whole page content into an image. But for the silverlight component its not able to capture it for obvious reasons.

Solution is that you need to take current screen image rather than relying on browser. One of the easiest way is to use Robot Framework SikuliLibrary. It also have Capture Region keyword which can take snapshot of specific part of the screen. I hope this would be sufficient for your requirement.

Sariq Shaikh
  • 940
  • 8
  • 29