whatsapp_btn
whatsapp_btn Chat With Us

Home >> QA Automation Q&A >> Zoom in/out Page Content Using Selenium WebDriver 

Zoom in/out Page Content Using Selenium WebDriver 

  3 min read
zoom in/out Page Content Using Selenium WebDriver

Zoom in/out Page Content Using Selenium WebDriver with `chromedriver` in Java, Python, and C#:

Java:


// Zoom in
String zoomJS;
JavascriptExecutor js = (JavascriptExecutor) driver;
zoomJS = "document.body.style.zoom='1.5'"; // Zoom level can be adjusted as needed
js.executeScript(zoomJS);

Python:


from selenium import webdriver

options = webdriver.ChromeOptions()
driver = webdriver.Chrome(executable_path='/path/to/chromedriver', chrome_options=options)

# Zoom in (e.g., 1.5x)
driver.execute_script("document.body.style.zoom = '1.5'")  # Zoom level can b

C#:


using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

ChromeOptions options = new ChromeOptions();
options.BinaryLocation = "/path/to/chromedriver";  // Specify the path to chromedriver executable
IWebDriver driver = new ChromeDriver(options);

// Zoom in (e.g., 1.5x)
((IJavaScriptExecutor)driver).ExecuteScript("document.body.style.zoom = '1.5


These examples demonstrate how to dynamically adjust and zoom in or out of a web page content using Selenium WebDriver with chromedriver in Java, Python, and C#. You can modify the zoom level as per your requirements.

These code snippets showcase how to perform zoom in and zoom out actions using Selenium WebDriver. They utilize the execute_script method to dynamically adjust the zoom level of the web page content. The zoom level can be customized as needed for specific testing and automation requirements.

 
Tagline Infotech
Tagline Infotech a well-known provider of IT services, is deeply committed to assisting other IT professionals in all facets of the industry. We continuously provide comprehensive and high-quality content and products that give customers a strategic edge and assist them in improving, expanding, and taking their business to new heights by using the power of technology. You may also find us on LinkedIn, Instagram, Facebook and Twitter.

Related Posts :

contact-us-bg

Our Global Presence

India

Surat (HQ)

Digital Valley, 423, Apple Square, beside Lajamni Chowk, Mota Varachha, Surat, Gujarat 394101

Ahmedabad

D-401, titanium city center, 100 feet anand nagar road, Ahmedabad-380015

 +91 9913 808 285

U.S.A

1133 Sampley Ln Leander, Texas, 78641

United Kingdom

52 Godalming Avenue, wallington, London - SM6 8NW

U.A.E

Office No - 43-44, Al Fahidi, Bur Dubai, Dubai, United Arab Emirates

 +971 58 569 4786