Tips for navigating through a webpage by scrolling

My goal is to automatically scroll down to the bottom of the page and then perform a specific action. With the help of uiautomator, I was able to retrieve the following information:

index=2,
resource-id=com.manoramaonline.arogyam:id/pager,class=android.support.v4.view.ViewPager,
scrollable=true.

I have made an attempt to achieve this using the code snippet below:

JavascriptExecutor js = (JavascriptExecutor) driver;
RemoteWebElement element =(RemoteWebElement)driver.findElement(By.xpath("//android.support.v4.view.ViewPager[@resource-id='com.manoramaonline.arogyam:id/pager']"));     
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");

// The issue lies here
scrollObject.put("element", element.getId());
js.executeScript("mobile: scroll", scrollObject);

Answer №1

After some trial and error, I finally managed to get it working using the following code snippet.

    WebElement scrollElement = driver.findElement(By.className("android.widget.ScrollView"));
    Actions actions = new Actions(driver);
    actions.moveToElement(scrollElement);
    // actions.click();
    actions.perform();

Answer №2

   With the JavascriptExecutor in play, you can initiate downward scrolling by utilizing a HashMap to specify the direction. This code snippet allows for customization in terms of how many times the scroll should occur, making it suitable for incorporating into a for loop. The drawback, however, lies in its lack of specificity. It's worth noting that this particular code was sourced from a response on GitHub, indicating that Appium struggles with executing accurate scrolls on iOS devices. 

This explanation sheds light on the limitations and challenges faced when attempting to implement proper scrolling functionalities using Appium on iOS platforms.

Answer №3

Appium has recently deprecated the "mobile : scroll" function, but fear not! The following code snippet will help you achieve the same results.

To scroll to specific text:

MobileElement radioGroup = (MobileElement) wd

.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()"

".resourceId(\"+<listview_id>+\")).scrollIntoView("

"new UiSelector().text(\"+<your_text>+\"));");

radioGroup.click();

Watch this video tutorial for more guidance: https://www.youtube.com/watch?v=bT3tqaLNn-Y

Answer №4

Grabbing the MobileElement radioGroup and finding it using wd.findElementByAndroidUIAutomator, with the specified criteria to scrollIntoView based on listview_id and your_text.

This method recommended by Manidroid works flawlessly for me.

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

Encountering this issue: Unable to access the property 'length' of an undefined variable

I'm currently developing an app using nuxt, vuetify 2, and typescript. Within the app, I have radio buttons (referred to as b1 and b2) and text fields (referred to as t1, t2, t3). When a user clicks on b1, it displays t1 and t3. On the other hand, w ...

Tips for declaring the OpenLayers map object globally

I have successfully created a map with ol 6 and added an OSM layer. Now I am trying to incorporate a vector layer that is coded in another JavaScript file, using the same 'map' object. Despite my efforts to declare it globally, it doesn't se ...

Navigating through a nested array within a JSON object using Vue.js - a guide

I have a JSON data array that includes outer and inner subarrays. My goal is to loop through both levels and create a table. Below you'll find a snippet of the sample array: { class:'I', subDdiv:[ { ...

Insert a design layout into a text entry box

Currently developing an application with AngularJS and seeking a solution for adding a "template" to an HTML input field similar to a placeholder. Specifically, I have a date-field requiring user input in the format of dd/MM/yyyy or through a datepicker se ...

Having trouble selecting a default option in a dynamically populated select dropdown using ng-model in the dropdown

For my Angularjs application, I needed to dynamically return a select drop down with its selected option. To accomplish this, I implemented the following function: function getCellRendererMapping(data) { if (data.order == 6) { return funct ...

Guide to managing authentication popups in Chrome using Selenium WebDriver in Java

I'm currently dealing with an authentication pop-up in one of my new Webdriver scripts. While I have a solution that works for Internet Explorer, I'm facing some challenges with Chrome. The approach for IE was straightforward - following the guid ...

JavaScript's replace() method and the $1 issue

My goal is to develop a script that can identify specific patterns within text and then enclose them in particular tags upon identification. $(".shop_attributes td").each(function () { $(this).html(function(i, html) { return html.replace(/E[0- ...

Font family 'anticon' is not recognized

While following a coding tutorial on YouTube, I encountered an error message that has me stumped. Despite having the correct import statement and dependency installed, the issue persists. Error message in iOS simulator: https://i.stack.imgur.com/LOVCQl. ...

Utilizing AngularJS filter in JavaScript without AngularJS Framework

This is a test to experiment and learn. Currently, I have a JSON object called obj. My goal is to utilize the angular Json filter to format this JSON object and display it in the chrome console. This should be achieved without the need for any button click ...

Tips on displaying substitute text in Angular when an Iframe fails to load the content located at the src

Currently, I am working on an Angular 12 application and have a requirement to fetch content from an external site and display it within a modal popup. To achieve this, I am using the <iframe src="url"> tag to retrieve the content from a se ...

Encountering an issue with the `className` prop not matching when deploying to Heroku, yet the functionality works perfectly when testing locally

I encountered this specific error message: The className property did not match. On the server: "jss1 jss5" Client side: "makeStyles-root-1 makeStyles-root-5" This issue only arises when deploying to Heroku. Locally, everything runs ...

Refresh ng-repeat array after implementing filter in controller

I am currently facing an issue with updating my table view when changing a variable that filters an array. The filter is applied in the controller based on the values of a specific variable called columnFilter. However, the filter does not reapply to updat ...

Tips for globally overriding MUIv4 class in JSS for nested themes

Summary: Skip to EDIT2 MUIv4 has generated the following classes for me based on my nested theming: <label class="MuiFormLabel-root-121 MuiInputLabel-root-113 MuiInputLabel-formControl-115 MuiInputLabel-animated-118 MuiInputLabel-shrink-117 M ...

Displaying a loading template within an Angular component

While reviewing some code in AngularJS version 1.2.22, I came across the following snippet in the HTML: <div class="mainContent" ng-include="content"> </div> Within its corresponding controller, I found this: $scope.content = 'templates ...

Changing an object received as a prop in Vue.js

Is it acceptable to mutate values in a prop when passing an Object reference? In the process of developing a web application that involves passing numerous values to a component, I am exploring the most efficient method of handling value passing between c ...

It appears that the NodeJs Express 4 async function in the model is returning before completion

I'm currently working on organizing my project by splitting the logic into different folders such as routes, views, models, and controllers. Within a model named data (models/datamodel.js), I have implemented two methods to retrieve data for populati ...

Is there a way to transfer the data from a chosen row into a different table?

My task involves using a table with two different conditions. In the first table, I display all incoming data. Then, in the second table (referred to as "select summary"), I want to show the row selected in the first table. To achieve this, I am utilizing ...

Using JQUERY to create a dropdown menu that dynamically changes based on the date field

I am currently working on a JQUERY project and facing a challenging situation. I usually know how to create dropdown menus that depend on one another, but this time I need a dropdown menu that displays age ranges based on the date entered in the birth-date ...

Access Vuex Getters in a separate JavaScript file

Within the file /store/user/getters.js: function getLoggedIn (state) { return state.loggedIn } In a different file, router-auth.js, I attempted to access the value (true or false) of getters.getLoggedIn in the following manner: import user from '.. ...

Display the same data point on a Google Map from two different rows of a database

I'm looking to display multiple values for profFName and profLName on a map with just one point showing this information. If I have (2) pID connected to the same marker, I want it to show both profFName and profLName on a single point. Currently, it ...