0

I am able to take screen shots of entire page by scrolling to window.innerheight but while combining facing proble of duplicate(position fixed Header/content) in all the pages. Is their any solution to resolve this problem. please post your answer clearly.enter image description here

FireFox open Developer Toolbar and hit shift + f2 then type this command.
screenshot d:\yash.png --fullpage Then it reduces the clientWidth and takes screenshot. Selenium-WebDriver FireFox-ScreenShot

Using selenium with IE(uncheck checkboxes of security & privacy and reduce Internet, Accept all cookies to zero). use ieCapabilities.setCapability("ignoreZoomSetting", true); then it takes screenshot of entire page by reducing the client width with out any Image pixel problem. but the Screen shot on this Site:http://help.dottoro.com/ljlumkqh.php is not as expected.

But in Chrome it takes only visible part of web page. In order to take whole page screen shot we need to scroll to clientHeight and combine all screen shots.

Community
  • 1
  • 1
Yash
  • 9,250
  • 2
  • 69
  • 74
  • Its selenium behaviour to take the full-page screenshot. We need not scroll explicitly to take a screenshot. – Praveen Jul 07 '15 at 08:55
  • In such case, the fixed position components will not be duplicated. (selenium will pick it only once by default) To add more info, please show us the image/screenshot captured. – Praveen Jul 07 '15 at 08:56
  • Not for Firefox driver. Fixed position poblem is for chrome,IE ... – Yash Jul 07 '15 at 09:19

3 Answers3

1

Remove Sticky Data

Window.getComputedStyle() method and its supported Browsers.

currentStyle object for IE before version 9

var elems = window.document.getElementsByTagName('*');
for(i = 0; i < elems.length; i++) { 
        if (window.getComputedStyle) {
             var elemStyle = window.getComputedStyle(elems[i], null); 
             if(elemStyle.getPropertyValue('position') == 'fixed' && elems[i].innerHTML.length != 0 ){  
                 elems[i].parentNode.removeChild(elems[i]);
             }
        alert (Works For all Browsers);
        }else {
             var elemStyle = elems[i].currentStyle; 
             if(elemStyle.position == 'fixed' && elems[i].childNodes.length != 0 ){ 
                 elems[i].parentNode.removeChild(elems[i]); 
             }
        alert (Works for IE browsers version below 9);
        }   
}       
Yash
  • 9,250
  • 2
  • 69
  • 74
0

First point is you don't need to scroll for taking full screen screen shot in selenium.

Approach for removing duplicate data:

  • Take complete window screen shot & don't save it to any file.
  • Observe the duplicate data (Header object)
  • Create bufferedImage object for the screen shot file using ImageIO.read() method.
  • Get the x & y co-ordinates for the duplicate part (Header) using .getLocation().getX()/getY() methods.
  • from whole screen shot remove the duplicate data by using .getSubimage() method.
  • then save the image to any file using ImageIO.write() method.
HemaSundar
  • 1,263
  • 3
  • 17
  • 28
0

I think there should be some code to support your question.

But, assuming that you are scrolling your page explicitly to take the screenshot.

Solution/Suggestion/Tip: Selenium by default scrolls the page to take the screenshot of the complete page.

Please refer the screenshot captured by the code.

Code to take the above screenshot:

    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.w3schools.com/html/default.asp");
    File myScreenShot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(myScreenShot, new File("D:\\ff.png"));

Refer this for more information on taking a screenshot.

Praveen
  • 1,387
  • 1
  • 12
  • 22