In a Selenium-based test case written in Java, how can one zoom in and out?

In a Selenium-based test case written in Java, how can one zoom in and out?

Hi Toby-steed,

To zoom in on a specific element on a web page using the Javascript executor, users can inject a script into the Javascript console. For guidance on how to accomplish this, please refer to the provided reference.

WebElement abc=driver.findElement(By.id(""file-submit""));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript(""document.body.style.zoom = '200%'"",abc);

Example

Zoom In: +200%

Zoom Out: -200%"