ChromeOptions可将浏览器缩放比例设置为80% [英] ChromeOptions to set browser zoom to 80%
本文介绍了ChromeOptions可将浏览器缩放比例设置为80%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我打开硒框架的浏览器时,我想将默认缩放值设置为80%.遵循以下内容. ChromeOptions是否可以做到这一点?
I would like to set the default zoom value to 80% when opening the browser for a selenium framework. Something along the lines of below. Is this possible with ChromeOptions.
private static ChromeOptions GetChromeOptions()
{
ChromeOptions options = new ChromeOptions();
options.AddArgument("--start-maximized");
options.AddArgument("Zoom 80%");
return options;
}
推荐答案
要将缩放级别设置为 80%
,您可以将 Javascriptexecutor
与以下任何一项配合使用以下选项:
To to set the zoom level to 80%
you can use Javascriptexecutor
with either of the following options :
((IJavaScriptExecutor)driver).executeScript("document.body.style.transform='scale(0.8)';");
或
((IJavaScriptExecutor)driver).executeScript("document.body.style.zoom='80%';");
注意:偏离
100%
的标准默认缩放值可能会影响Web Browsers
Note : Deviating from the standard default zoom value of
100%
may impact the functioning of theWeb Browsers
这篇关于ChromeOptions可将浏览器缩放比例设置为80%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文