Can we Zoom the browser window in python selenium webdriver?

后端 未结 5 727
不思量自难忘°
不思量自难忘° 2020-12-14 10:52

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
driv         


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-14 11:34

    As you mentioned that Need it to work in Chrome. The current solutions are only for Firefox, here are a few updates and options :

    1. Zoom the CSS :

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

      This option did work for me. But it zooms the CSS, not the Chrome Browser. So probably you are not looking at that.

    2. Zoom In & Zoom Out the Chrome Browser :

    After 4131, 4133 and 1621 the fullscreen() mode got supported to Zoom In through Selenium-Java Clients but it's not yet publicly released to PyPI.

    I can see it's implemented but not pushed. Selenium 3.7 (Python) will be out soon. The push to sync version numbers will include that.

    1. Configure the webdriver to open the Browser :

    If your requirement is to execute the Test Suite in Full Screen mode, you can always use the Options Class and configure the webdriver instance with --kiosk argument as follows:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    options = Options()
    options.add_argument("--kiosk")
    driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
    driver.get('https://www.google.co.in')
    

提交回复
热议问题