Skip to main content
 首页 » 编程设计

python之如何使用 python selenium 缩小页面

2025年05月04日13bonelee

我为 java 找到了这个:-

WebElement html = driver.findElement(By.tagName("html")); 
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD)); 

但是如何使用 Python 做到这一点呢?我想在收到请求后缩小一级。

请您参考如下方法:

这为使用 selenium (-v 3.141.0) 的 Python 完成了工作

driver = webdriver.Chrome(executable_path='...') 
driver.get("www.stackoverflow.com") 
driver.execute_script("document.body.style.zoom='50%'")