Exploring scroll functionality with Webdriver.io v4

My code is designed to log into the beta version of mediawiki, navigate to the Preferences page, and attempt to click on a button located at the bottom of the page.

In order to achieve this, I am utilizing the scroll() function because using only .click() results in an error, much like the one described below. However, I have encountered an issue where .scroll() does not produce the desired effect.

The version of WebdriverIO being used for this project is version 4.

Approaches I've taken:

  1. I initially attempted the test with just elem.click(), without any scrolling, which led to an error message stating that the element was not clickable.

  2. Running the code without elem.click() caused the test to pass, but there was no visible scrolling on the page (To verify, I added browser.pause(9000); at the end).

  3. When experimenting with .scroll() and providing values such as elem.scroll(0,500), the page did scroll down, but not sufficiently to view the intended element.

  4. I also tested .moveToObject(), which resulted in some scrolling on the page but still not enough to interact with the element. Passing values to this function did not yield successful results either.


it('should demonstrate the scroll command on the Preferences Page ', function () {
    // login 
    browser.url('https://en.wikipedia.beta.wmflabs.org/w/index.php?title=Special:UserLogin&returnto=Main+Page');
    var loginName = $('#wpName1');
    var loginPass = $('#wpPassword1');
    var loginBtn = $('#wpLoginAttempt');
    loginName.setValue('Ephemeraltest');
    loginPass.setValue('vagrant123');
    loginBtn.click();

    // click button at bottom of preferences page
    browser.url('https://en.wikipedia.beta.wmflabs.org/wiki/Special:Preferences');
    var elem = $('#ooui-php-41');

    elem.scroll();
    elem.click();
});

Upon running the code, the following error is displayed:

unknown error: Element ... is not clickable at point (602, 571). Another element would receive the click: ... running chrome Error: An unknown server-side error occurred while processing the command. at elementIdClick("0.7032716938931156-1") - click.js:20:22

Answer №1

Did you give the scrollIntoView method a shot? If not, here's a snippet to try out: Use selector as '#ooui-php-41'

        browser.execute(elem => elem.scrollIntoView(), browser.element(selector).value);

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

Assign a property to an array of objects depending on the presence of a value in a separate array

Looking to manipulate arrays? Here's a task for you: const arrayToCheck = ['a', 'b', 'c', 'd']; We have the main array as follows: const mainArray = [ {name:'alex', code: 'c'}, ...

Tips for delaying the evaluation of an <input> field?

I am interested in analyzing the content of an <input> field when there is no activity from the user. One simple example I have considered is counting the number of characters, but the actual analysis process is very resource-intensive. To optimize ...

Is it possible to request/scrape pages from the client side?

Let me present the issue at hand: I am currently managing a web application that serves as a notification system which updates frequently. This application is operational on several local computers, each of which solely display information without any inp ...

Tips for altering the class of an HTML button dynamically when it's clicked during runtime

I currently have a set of buttons in my HTML page: <button id="button1" onclick="myFunction()" class="buttonClassA"></button> <button id="button2" onclick="myFunction()" class="buttonClassA"></button> <button id="button3" onclic ...

Mastering the Art of Promises in RXJS Observables

After thoroughly researching SO, I stumbled upon numerous questions and answers similar to mine. However, I suspect that there might be gaps in my fundamental understanding of how to effectively work with this technology stack. Currently, I am deeply enga ...

The Google Maps feature encountered an error (ReferenceError: google is not defined)

Utilizing the Google Maps API on my website to display multiple locations has been successful so far. However, an issue arises when attempting to determine the distance between two sets of latitude and longitude coordinates - resulting in an error message ...

Guide to importing an AngularJS controller into an Express file (routes.js)

Currently, I am in the process of developing a restful service and my goal is to organize my callbacks within controllers in order to avoid cluttering my routes.js file. Previously, I had been using controller = require(path.to.controller); This enabled ...

Protractor and Gulp: Selenium WebDriver terminated with status code 1

I've recently encountered an issue while using Bangular, a fantastic MEAN stack Yeoman generator, to create a project. Everything was running smoothly until I performed a series of npm updates on the project. Now, when attempting to run the gulp-protr ...

What is the most efficient method for managing window properties and child components in React/Redux?

My <Layout> component loads different child components based on the page. Some of these children may have tabs, while others may not. This variation in content affects how scrolling should work and consequently influences the structure of the scroll ...

Efficient guide to unlock the secrets of JS height measurements

I've noticed that there are several different 'Height' related properties in JavaScript such as clientHeight, Window.height, scrollHeight, offsetHeight, and more. Although I have a general idea of what they do, I am seeking a formal and det ...

Issue encountered while attempting to log out a user using Keycloak in a React JS application

I'm currently working on implementing authentication for a React JS app using Keycloak. To manage the global states, specifically keycloackValue and authenticated in KeycloackContext, I have opted to use React Context. Specific Cases: Upon initial r ...

Using ${} syntax to implement dynamic logic when constructing a string in Express.js

I need to iterate through an object and display values for each one while creating a string. Any suggestions on how to achieve something like this: const body = ` <h1>Values</h1> ${ for (value in values) { return `<h2>Ind ...

Unable to retrieve data on the frontend using Node.js and React

I have been attempting to retrieve all user data from the backend to display on the webpage. However, it seems that the getAllUsers() function is not returning a response, as no console logs are being displayed. Here is my ViewUsers.js file: import React, ...

What is the difference in memory usage for JavaScript objects between Node.js and Chrome?

It's puzzling to me why the size of the heap is twice as large as expected. I meticulously constructed a binary tree with perfection. I suspect v8 recognizes that each node consists of 3 fields. function buildTree(depth) { if (depth === 0) return n ...

When downloading files in Chrome or Safari, the $ajax call is in a pending state, whereas in IE or Firefox,

Measuring the time it takes to download a 1MB file using AJAX calls. Below is the code snippet: var start = new Date(); $(document).ready(function() { $.ajax ({ url: 'https://www.example.com/dummyFile1024', crossDomain: t ...

Obtaining the designated item within the list

My list contains elements obtained from a database. I want to ensure that the selected elements remain visible at all times, even after refreshing the page. Here's an example: <select id="select-firm" class="form-control" name="firmId" size="20" ...

When using React with Firebase, remember to specify the "to" property when using setState to avoid errors

Struggling to figure out what's going wrong after hours of trying. I'm new to React and would really appreciate your help. Initially, my state was an array of accommodations which I mapped over successfully. However, once I connected Firebase wit ...

Using Choices.js to inject live data into the select dropdown options

I am currently utilizing Choices.js for multi-select functionality and incorporating a select with a search box. Even though I am using Angular.js to populate the data, it does not appear to be functioning correctly. Is there anyone who can assist me in dy ...

Using Nested ng-repeat for Values and Keys in Angular

Struggling with implementing nested ng-repeats in my code. I have a JSON object with multiple layers and attempting to iterate through them to display the data. Here is the structure of the JSON: { "status": "success", "data": { "Mat": { "tota ...

Issue with Vuex getter not reflecting correct value after modifying an array

I've been delving into the world of vuex, and I'm currently working on fetching the count or an array when I make additions or removals. Below, you'll find the code snippets I'm working with. home.vue template <template> < ...