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, 2019 in Selenium by Ruhi
4,495 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, 2019 by Anvi
• 14,150 points

Related Questions In Selenium

0 votes
1 answer
+1 vote
2 answers

Is it possible to scroll down in a webpage using selenium webdriver programmed on python?

I using next code for facebook for ...READ MORE

answered May 16, 2019 in Selenium by mslavikas@gmail.com
21,989 views
0 votes
2 answers

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,520 points
5,099 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,010 points
5,832 views
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,890 points
3,599 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2, 2020 in Selenium by Sri
• 3,010 points
4,339 views
0 votes
1 answer

How can I perform multiple selection of options in a dropdown using Select class in Selenium?

Hey Priyansh, you can select multiple options ...READ MORE

answered Jul 8, 2019 in Selenium by Anvi
• 14,150 points
1,503 views
0 votes
1 answer