如何在C#中使用IJavaScriptExecutor更改硒Web驱动程序中的页面缩放级别?
我尝试了以下方法,效果很好:
public void ZoomIn()
{
new Actions(Driver)
.SendKeys(Keys.Control).SendKeys(Keys.Add)
.Perform();
}
public void ZoomOut()
{
new Actions(Driver)
.SendKeys(Keys.Control).SendKeys(Keys.Subtract)
.Perform();
}
我正在尝试使用以下代码实现相同的功能,并且不会带来缩放级别的任何变化:
Driver = new ChromeDriver(service, chromeResolutionOptions, TimeSpan.FromMinutes(3));
IJavaScriptExecutor executor = (IJavaScriptExecutor)Driver;
executor.ExecuteScript("document.body.style.zoom = '200%'");