
Announcements
Hello everyone,
I’m currently working on automating a task to scroll through a specific section of a LinkedIn page, and I’m running into some challenges. I’ve attempted several JavaScript-based approaches to achieve this, but none have worked so far. Here’s what I’ve tried:
Using JavaScript for Webpage Actions:
I wrote multiple scripts to programmatically scroll the element with the specified class. For example, I used methods like scrollTop and scrollIntoView. Unfortunately, none of these scripts scrolled the section as expected.
Focusing on the Last Element:
I tried selecting the last element within the target section and using scrollIntoView() to focus on it and also Focus on text action. However, it keeps showing an error stating that the element cannot be found.
Mouse Move Action:
I attempted to simulate a mouse move action within the section to scroll, but it didn’t produce any results. I suspect this might be due to LinkedIn’s dynamic loading or event handling.
If anyone has successfully implemented a solution to scroll a specific part of a webpage with similar constraints, I’d greatly appreciate your guidance. Are there any specific JavaScript methods, browser extensions, or tools that can help in this scenario?
function ExecuteScript() {
const scrollSpeed = 5; // Pixels per step
const delay = 10; // Milliseconds between steps
const targetElement = document.querySelector("[class^='customScrollBar']"); // Select element with class starting with 'customScrollBar'
if (!targetElement) {
console.error("Element with class starting with 'customScrollBar' not found.");
return;
}
function scrollStep() {
targetElement.scrollBy(0, scrollSpeed);
if (targetElement.scrollHeight - targetElement.scrollTop > targetElement.clientHeight) {
setTimeout(scrollStep, delay);
}
}
scrollStep();
return "end" //just so Result returns something other than object Obect
}