How to create a scrolling window embedded within a different page using Selenium in Java

Looking to scroll a section of a page within another page. Check out the screenshot below:

https://i.sstatic.net/qHH9x.png

I attempted to achieve this with the following code snippet:

JavascriptExecutor js1 = (JavascriptExecutor) driver;
js1.executeScript("window.scrollBy(0,1000)");

However, the code ends up scrolling the entire page rather than the specific window inside the page. How can I specify that I only want to scroll this particular window?

Thank you in advance!

Answer №1

Feel free to experiment with the following code snippet. It has been found effective in many scrolling scenarios:

WebElement webElement = driver.findWebElement(By.xpath("xpath_Of_Element"));                 
js.executeScript("arguments[0].click();",webElement);

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

Tips on bringing data from a php file into a javascript variable

I'm faced with a challenge where I need to extract data from a MySQL database using a PHP file and then store that data in a JavaScript array for plotting purposes with jQuery's flot library. Has anyone encountered a similar situation and found a ...

Creating a Modal in React without the need for a button to trigger it

I am working on implementing a model using the React Material UI library to display information on the landing page when a user logs in. However, I am facing an issue with closing the modal once it appears despite using a timeout trigger. const[post,setP ...

Creating an effortless RSS feed using jQuery and Ajax

I could use some assistance with creating a basic rss feed that pulls content from websites like arstechnica. I've spent the last few hours researching how to do this, but I'm feeling a bit lost on the correct approach. Currently, I'm trying ...

Is there a reliable and fully operational Selenium WebDriver available for use with MS Edge browser?

While this question has been raised in the past, there hasn't been much recent information on the topic. So, is there a functional Selenium WebDriver available for MS Edge? The only version I could locate, also referenced on seleniumhq.org, dates bac ...

Dim the background for all elements except for one

Seeking a way to create a dimmed-background effect by adjusting the opacity of all elements on the page except for one specific element. I've experimented with using the :not() selector as well as jQuery selectors to exclude certain elements, but have ...

What causes the excessive memory usage of (JS)Strings when loading complex .obj files in AFrame and Three.js?

Our webscene is quite complex, with dynamically loaded .obj and .mtl files. When comparing the scene without any objects to one with multiple objects, we noticed a strange issue: In Firefox's memory heap, most of the memory (>100MB for 5 objects) ...

Using Vue.js causes an issue with Array.from(Object).forEach

When using vue.js 2 CLI, I typically define object data like this within the data() function: data(){ return{ user: { user_mail: '', user_password: '', user_confirm_password : '' ...

Gulp is ensuring the destination file remains unchanged

I'm encountering an issue with gulp in my project. I've set up a process to automate the compilation of source and styles into a single file using gulp. However, I'm facing a problem where it doesn't want to overwrite the `application.j ...

The method element.isDisplayed() is indicating a false value even though the element is visibly present on the screen

element.isDisplayed() is returning false even though the element is visible on the screen, causing issues with clicking on it. I attempted to use the code below, but without success. Actions cursor = new Actions(driver); cursor.moveTo ...

Adding a collection of items to an array in preparation for organizing

Realizing that sorting objects is not feasible - despite the necessity of having the object values sorted - I conclude that the only option is to move the object array content into a new array for sorting purposes. The following code generates the output ...

Using discord.js to conveniently set up a guild along with channels that are equipped with custom

When Discord devs introduced this feature, I can't seem to wrap my head around how they intended Discord.GuildManager#create to function. How could they possibly have expected it to work with Discord.GuildCreateOptions#channels[0], for instance, { ...

Encountering numerous errors when attempting to incorporate lottie-web into my JavaScript file

I am in the process of creating a unique audio player for my website utilizing HTML, CSS, and JavaScript. I encountered some challenges while trying to get it to work effectively on Codepen as well as my text editor. The animations were not functioning pro ...

Show a logout option inside a toolbar using a popup alert

[I'm seeking assistance on how to implement a logout function with an alert dialog in a toolbar. I want the alert dialog to prompt users when they attempt to log out of their account. As I am currently in the learning process, any help would be greatl ...

The touchstart event handler triggers but the event returns as undefined

@ontouchdown="handleTouch(event)" handleTouch(event) { console.log(event); console.log("touch event"); } Why is the event not being passed properly? ...

Basic web application leveraging PostgreSQL database and Tomcat server

I'm currently working on a tutorial to develop a basic web application using PostgreSQL as the database with Hibernate, Tomcat as the server, and Eclipse as the IDE. The requirement is for the user to input their name, surname, and country into a sim ...

Changing the class name in HTML depending on the size of the screen

I'm attempting to dynamically change the class tag's name when a user visits the page based on the screen size. Below is the code snippet I've used: <!DOCTYPE html> <html> <body onload="changeClass()"> <section class=" ...

executing jQuery toggle on freshly generated content

I have a webpage that I designed using jQuery. Within this page, there is a table with rows assigned specific color classnames (e.g., tr class="yellowclass"). Users can filter the rows by clicking checkboxes to show/hide tables of different colors. The i ...

Tips on populating a text input field using ajax

This is the Jquery and ajax code I have written to load text box data sent from the server class. I am receiving a response, but for some reason, the data sent from the server is not loading into the textbox. You can see the error here. $(document).read ...

Match one instance of a character in a regular expression pattern while simultaneously matching two occurrences of a different character

I am attempting to create a function that can match one occurrence of a certain character and two occurrences of another character simultaneously. For instance, in the string "_Hell_o", I want to match the first underscore (_) and in the string "++Hello", ...

When evaluating code with eval, properties of undefined cannot be set, but the process works seamlessly without

Currently, I am attempting to utilize the eval() function to dynamically update a variable that must be accessed by path in the format myArray[0][0[1][0].... Strangely enough, when I try this approach, I encounter the following error: Uncaught TypeError: ...