Selenium禁用位置固定内容在删除整个页面时删除重复数据屏幕截图 [英] Selenium To disable Position fixed Content To remove Duplicate data while taking Whole Webpage Screen shot

查看:368
本文介绍了Selenium禁用位置固定内容在删除整个页面时删除重复数据屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我可以通过滚动到window.innerheight来拍摄整个页面的屏幕截图,但同时结合面对重复的问题(位置固定的标题/内容) em>是他们的任何解决方案来解决这个问题。请清楚回复您的回答。



FireFox 打开开发人员工具栏 a>,然后按shift + f2,然后键入此命令。

屏幕截图d:\yash.png --fullpage
clientWidth并截取屏幕截图。
Selenium-WebDriver FireFox-
ScreenShot

使用 selenium与 IE (取消选中安全和隐私复选框并减少互联网,接受所有Cookie为零)。
使用 ieCapabilities.setCapability(ignoreZoomSetting,true);
然后它通过减少客户端宽度与任何图像像素问题。但在本网站上的屏幕截图: http://help.dottoro.com/ljlumkqh.php 不是预期的。



但在 Chrome 中,只需网页的可见部分。为了采取
整页屏幕截图,我们需要滚动到clientHeight并组合所有
屏幕截图。

解决方案

删除粘滞数据



窗口。 getComputedStyle()方法及其支持



currentStyle object for IE before version 9

  var elems = window.document.getElementsByTagName('*'); 
for(i = 0; 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 [一世]);
}
alert(适用于所有浏览器);
} else {
var elemStyle = elems [i] .currentStyle;
if(elemStyle.position =='fixed'& elems [i] .childNodes.length!= 0){
elems [i] .parentNode.removeChild(elems [i]);
}
alert(适用于IE浏览器版本9以下);
}
}


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.

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.

解决方案

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);
        }   
}       

这篇关于Selenium禁用位置固定内容在删除整个页面时删除重复数据屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆