wdio-screenshot
wdio-screenshot copied to clipboard
Screenshots of fixed elements
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:
- detect if element's position is fixed or if a parent is fixed
- if it isn't a fixed element, take the screenshot as usual
- 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;
}