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 24, 2019 in Selenium by Ruhi
11,877 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
26,073 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,500 points
13,673 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,190 points
9,142 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,910 points
7,221 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 3, 2020 in Selenium by Sri
• 3,190 points
7,874 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
3,221 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP