0

I am trying to capture images of the content area of an web application I am testing.

I need to eliminate the browser menus from my images, so the user can compere the content images between different browsers.

This should run on any PC resolution and on any browser.

The given selenium methods provide a way to capture the entire window:

Selenium.CaptureScreenshot(filename),
Selenium.CaptureEntirePageScreenshot(filename,kwargs)

Also when trying to calculate the size of the frame selenium give a pixel count relative to the browser frame, which means that (0,0) is the upper left point of the browser not the screen.

How can I capture the relevant content area using selenium combined with .NET?

casperOne
  • 73,706
  • 19
  • 184
  • 253
  • When I was using first selenium, CaptureScreenshot didn't work for me. To make selenium to work what I want I had to use selenium webdriver. Maybe try here: http://stackoverflow.com/questions/3422262/take-a-screenshot-with-selenium-webdriver – deadfish Nov 06 '11 at 19:02

2 Answers2

1

I agree with Patterson to use CaptureEntirePageScreenshotToString instead of CaptureEntirePageScreenshot.

Secondly for comparison you require any image comparison utility that do the job of comparing two image or portion of image for example ISFW provide ImageCompareUtil for java implementation. In your case you need to compare portion of captured image to base one. Still you will require some logic for cross-browser for ex in case of FF the captured image will include entire page content while in case of IE it include only visible contents.

For different resolution you can resize browser window to expected resolution before capturing screen shot.

Hope this will helps.

user861594
  • 5,733
  • 3
  • 29
  • 45
0

Sounds like you already know the answer. We use Selenium.CaptureEntirePageScreenshotToString(), because we run our tests in a way that may not have the browser and the test script running on the same system, but it uses the same code at the core as Selenium.CaptureEntirePageScreenshot() does. The only difference is that our way returns a BASE64-encoded PNG image, so we don't have to get it from disk.

Ross Patterson
  • 9,527
  • 33
  • 48