Can we perform zoom-in or zoom-out actions in a webpage using Python Selenium?

0 votes
Can we perform zoom-in or zoom-out actions in a webpage using Python Selenium?
Jul 23 in Selenium by Ruhi
282 views

1 answer to this question.

0 votes

Hello Ruhi, to perform Zoom-in or Zoom-out actions on a webpage, you have to use transform CSS property which allows you to perform zoom in, zoom out, rotate or skew on a webpage. Checkout the following automation script to understand better:

from selenium import webdriver
from time import sleep

driver = webdriver.Firefox()
driver.get("https://www.youtube.com/")
timeout = 10

''' Zoom in by 150% '''
driver.execute_script('document.body.style.MozTransform = "scale(1.5)";')
driver.execute_script('document.body.style.MozTransformOrigin = "0 0";')

sleep(10)

''' Zoom out by 100% '''

driver.execute_script('document.body.style.MozTransform = "scale(1.0)";')
driver.execute_script('document.body.style.MozTransformOrigin = "0 0";')

sleep(10)

driver.quit()
answered Jul 29 by Anvi
• 13,960 points

Related Questions In Selenium

0 votes
1 answer
+1 vote
2 answers
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
1,160 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,150 points
1,253 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,150 points
1,010 views
0 votes
1 answer
0 votes
1 answer