Is it possible to replicate the zoom text feature found in mobile browsers using selenium?

My automation script, which utilizes Selenium and Java on Sauce Labs, is presenting a challenge. I am struggling to find a JavaScript method or keyboard shortcut that can programmatically enable the 'Zoom text' function. Any advice or suggestions would be greatly appreciated. view image here

I have attempted the following JavaScript code, however it only zooms the entire page and not just the text: "document.body.style.zoom = '1.5'"; // Zoom in

Answer №1

If you want to change the font size from "medium" to "large" in Java, simply include the following preferences within 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 font sizes for "medium" are 13 and 16. You can adjust the font size settings and then visit chrome://prefs-internals/ to observe the changes in values.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Determining when the clear button is clicked in a v-select (vue-select) detection strategy

While working on creating a drop-down using v-select, I encountered an issue. After selecting an option, I needed to clear the drop-down and revert the option array back to its initial stage upon clicking the clear button. I attempted various methods such ...

Setting default parameters for steps in Selenium and Cucumber: How is it done?

I'm new to using Cucumber and I have a question regarding how to enforce strict parameters in the testcase.feature. For instance: And User click Delete on task action Currently, my step definition allows for any parameter because I use (.*). How ...

Learn how to display or conceal the HTML for 'Share this' buttons on specific routes defined in the index.html file

Currently, I am in the process of updating an existing Angular application. One of the requirements is to hide the "Share this buttons" on specific routes within the application. The "Share" module typically appears on the left side of the browser window a ...

Shrink Font-Awesome icon sizes using a Node.js and Express.js web application

Currently, I am in the process of developing a website using node.js + express.js and implementing font-awesome for icons. The local hosting of Font-awesome has resulted in a 1.2 MB JS file [font-awesome.js], even though we are only utilizing 10-15 icons. ...

Retrieving the variable value instead of a reference using Ajax in ASP

After spending nearly two days trying to figure out this code and researching every possible solution, I still haven't been able to get it to work properly. It's likely that I'm implementing it incorrectly or missing something, so I've ...

Guide on creating a fluid line in Three.js by connecting two points while clicking the mouse, using buffer geometry

Looking for assistance with drawing dynamic lines on mouse events in a threejs webgl canvas using buffergeometry and raycasting. Any help would be greatly appreciated! ...

Is it feasible to develop a Grafana datasource plugin that does not rely on an external backend system?

I am in the process of developing a Grafana datasource plugin that operates independently without relying on an external backend. My plugin is based on the simple-json datasource plugin available at: https://github.com/grafana/simple-json-datasource In a ...

Modify the color of the table map based on specific conditions in a React.js application

To modify the table entry's color based on the current balance, follow these conditions: If the current balance is less than 100, it should be shown in red. If the current balance is between 100 and 200, display it in yellow. Otherwise, show it in gre ...

What could be causing this issue with my JavaScript code?

Here is the code I have: <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="style.css"> </head> <body> <script type="module"> import * a ...

The vertical alignment of the navbar menu is off on smaller screens and the positioning of the hamburger menu needs adjustment

I have noticed that my top menu and submenu display correctly on a normal screen size. However, when the screen size is reduced, the menus and submenus do not align vertically as expected with Bootstrap. Instead, they appear misaligned. How can I adjust th ...

What is the best way to make the first value of a text box non-editable in React JS

I am working on creating a text box field to generate a country code. The requirement is to have the first letter as a "+" symbol and make it a non-editable field for that symbol. _handlePhoneNumber(e) { var curState = {}; var valueLength = e.ta ...

How can I eliminate the border appearance from a textfield fieldset component in Material-UI?

I have been struggling to remove the border using CSS code I found on Stack Overflow, but unfortunately, the issue persists. If anyone could kindly assist me in fixing this problem, I would be extremely grateful. Can someone please advise me on the specif ...

HtmlUnitDriver encountered an issue with java.lang.NoClassDefFoundError for com/gargoylesoftware/htmlunit/WebWindowListener

For my Selenium Headless Testing, I developed a Java class named htmlUnitTest. This class navigates to the Google website, enters text in the search box, performs a search, retrieves the page title, and then displays it in the Eclipse console. However, upo ...

Securing API endpoints in a React/Redux application using proxy techniques

Ensuring the security of my react/redux application is a top priority for me. I've noticed that my api url is exposed to the public inside the bundled app.js file, which raises some concerns. After doing some research, I discovered that some developer ...

Choose the sequence in which CSS Transitions are applied

Currently facing an interesting challenge, but I'm confident there's a clever solution out there. The issue at hand is with a table that has three different sorting states for its columns: unsorted, where no icon should be displayed, ascending, ...

A missing definition for req.body.object

The issue with the req.body.object variable persists. Even though I have body parser imported, the value remains undefined when I try to console.log() it. //javascript const express = require('express'); var bodyParser = require('body-pa ...

Moving the mouse to a specific point using Selenium Webdriver

I'm currently attempting to relocate the cursor to a specific point (org.openqa.selenium.Point) that has been identified by detecting a marker on a live chart. Although I cannot retrieve any details from this marker, I do have access to its X and Y co ...

Retrieve the product IDs by selecting the checkboxes, then compile a fresh array consisting of the identified IDs

I am currently delving into the realm of typescript/angular2+ as a fledgling student, and I have taken on the task of creating a website to put my newfound knowledge to the test. The view is up and running, but I'm facing some roadblocks as I work on ...

Where to begin with Angular materials?

Here is a snippet of my Angular materials test code: <div class="radioButtondemoBasicUsage" ng-app="MyApp"> <form ng-submit="submit()" ng-controller="AppCtrl"> <p>Selected Value: <span class="radioValue">{{ data.group1 }}< ...

What is the best way to use a Handlebars file on multiple routes?

I have been working on extracting articles from a news website by scraping them successfully. The data is being displayed properly on the front-end console log, but I am facing an issue with rendering it onto the page using a button - it only appears when ...