wdio-screenshot icon indicating copy to clipboard operation
wdio-screenshot copied to clipboard

Screenshots of fixed elements

Open zinserjan opened this issue 8 years ago • 0 comments

Screnshots of elements with position: fixed are currently not supported. But it would be nice to support that.

I think this can be done in the following way:

  1. detect if element's position is fixed or if a parent is fixed
  2. if it isn't a fixed element, take the screenshot as usual
  3. when it's fixed, just take a screenshot of the viewport (without css-scroll) and crop it as needed

We coud use a simple script to detect if the element is fixed, like the following:

function isFixed(elem){
  do {
    if (window.getComputedStyle(elem).position == 'fixed') {
      return true;    
    } 
  } while (elem = elem.offsetParent);
  return false;
}

zinserjan avatar Nov 30 '16 21:11 zinserjan