簡體   English   中英

如何在 selenium python 或使用 selenium 庫的機器人框架中使用鼠標放大網頁?

[英]How to zoomin the webpage using mouse in selenium python or robot framework using selenium library?

我想使用機器人框架 selenium 庫測試 web 應用程序的縮放功能。 還想知道是否可以在 python 中使用 selenium webdriver 來完成。

我想放大網頁。

為此,我嘗試了類似下面的方法

from selenium.webdriver.common.action_chains import ActionChains

ActionChains(driver).move_to_element(canvas_element)
.send_keys(Keys.chord(Keys.CONTROL, Keys.ADD)).build().perform();

但這在下面給了我一個錯誤

AttributeError: type object 'Keys' has no attribute 'chord'

我怎樣才能解決這個問題。 有人可以幫我謝謝。

已編輯

試試這個:

driver.execute_script("document.body.style.zoom='40%'")

然后使用以下命令恢復正常縮放:

driver.execute_script("document.body.style.zoom='100%'")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM