How do I Print an Exception in Python?
April 29, 2024
Home >> QA Automation Q&A >> Zoom in/out Page Content Using Selenium WebDriver
Zoom in/out Page Content Using Selenium WebDriver with `chromedriver` in Java, Python, and C#:
// 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);
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
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.
Digital Valley, 423, Apple Square, beside Lajamni Chowk, Mota Varachha, Surat, Gujarat 394101
D-401, titanium city center, 100 feet anand nagar road, Ahmedabad-380015
+91 9913 808 2851133 Sampley Ln Leander, Texas, 78641
52 Godalming Avenue, wallington, London - SM6 8NW