Can we mimic the zoom text function in the mobile browsers using selenium

37 views Asked by At

I am utilizing Sauce Labs to execute my automation script, which is built using Selenium and Java. One of the challenges I'm currently facing is finding a JavaScript method or keyboard shortcut to enable the 'Zoom text' function programmatically. Can you provide any guidance or suggestions? enter image description here

i tried following java-script.but that is doing page zoom not the text zoom "document.body.style.zoom = '1.5'"; // Zoom in

1

There are 1 answers

0
titusfortner On

To increase from "medium" to "large" font size in Java, add these preferences in your options class:

ChromeOptions options = new ChromeOptions();
Map<String, Object> preferences = ImmutableMap.of("webkit",
        ImmutableMap.of("webprefs",
                ImmutableMap.of("default_fixed_font_size", 17,
                        "default_font_size", 20)));
options.setExperimentalOption("prefs", preferences);

WebDriver driver = new RemoteWebDriver(sauceUrl, options);

The default ("Medium" is 13 & 16). You can set the font size in settings and navigate to this page to see the values change: chrome://prefs-internals/