本文介紹了我們可以在 python selenium webdriver 中縮放瀏覽器窗口嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我正在嘗試僅使用鍵盤放大和縮小 Chrome(硒網(wǎng)絡(luò)驅(qū)動程序).我試過了--
I am trying to ZOOM IN and ZOOM OUT the Chrome( selenium webdriver) only using keyboard. I have tried --
from selenium.webdriver.common.keys import Keys
driver.find_element_by_tag_name("body").send_keys(Keys.CONTROL,Keys.SUBTRACT).
但它不起作用.需要python中的答案.
but it is not working. Need answer in python.
推薦答案
我只是在為此苦苦掙扎.我設(shè)法找到了對我有用的東西,希望它對你有用:
I was just struggling with this. I managed to find something that works for me, hopefully it works for you:
driver.execute_script("document.body.style.zoom='zoom %'")
擁有 'zoom%' = 你想要的任何縮放級別.(例如67%")
Have 'zoom%' = whatever zoom level you want. (e.g. '67%')
這篇關(guān)于我們可以在 python selenium webdriver 中縮放瀏覽器窗口嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!