How can I point the mouse to a specific part of the page and then scroll? (puppet)


James Bow

The URL I would say is https://www.vudu.com/content/movies/movieslist . I'm trying to scroll through the section where the movie is. When I use the following code it doesn't work.

await page.evaluate( () => {
        window.scrollBy(0, window.innerHeight);
    });

I think this is because you naturally have to hover over the movie before the section scrolls. How can I solve this problem? Thanks!

my full code:

const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({ headless: false });
    const page = await browser.newPage();
    await page.setViewport({ width: 1280, height: 800 });
    url = "https://www.vudu.com/content/movies/movieslist"
    await page.goto(url, {waitUntil: 'load'});
    await page.evaluate( () => {
        window.scrollBy(0, window.innerHeight);
    });
    await page.waitFor(2000);
})()
vsemozhebuty

You can use this, but since the document body is not scrollable this doesn't seem to solve the problem. You need to find the scrollable element to scroll it:mouse.move()

'use strict';

const puppeteer = require('puppeteer');

(async function main() {
  try {
    const browser = await puppeteer.launch({ headless: false, defaultViewport: null });
    const [page] = await browser.pages();

    await page.goto('https://www.vudu.com/content/movies/movieslist');
    await page.waitForSelector('.nr-pt-40');

    const data = await page.evaluate(() => {
      const container = document.querySelector('.nr-pt-40');
      container.scrollBy(0, container.clientHeight);
    });

    // await browser.close();
  } catch (err) {
    console.error(err);
  }
})();

Related


How can I direct the user to a specific part of the page?

Ilia Tapia I have a page with a login form. This form is separated by two tabs. In the footer I have a link that should direct the user to this page, this form but on a second tab. what have i tried? I tried to access, #idbut since the table is mat-tab and ng-

How can I direct the user to a specific part of the page?

Ilia Tapia I have a page with a login form. This form is separated by two tabs. In the footer I have a link that should direct the user to this page, this form but on a second tab. what have i tried? I tried to access, #idbut since the table is mat-tab and ng-

How can I direct the user to a specific part of the page?

Ilia Tapia I have a page with a login form. This form is separated by two tabs. In the footer I have a link that should direct the user to this page, this form but on a second tab. what have i tried? I tried to access, #idbut since the table is mat-tab and ng-

How can I direct the user to a specific part of the page?

Ilia Tapia I have a page with a login form. This form is separated by two tabs. In the footer I have a link that should direct the user to this page, this form but on a second tab. what have i tried? I tried to access, #idbut since the table is mat-tab and ng-

jQuery scroll to specific point with mouse wheel

Mike Lundina I found a JSFiddle that works great for using autoscroll between divs. Here is the script : http://jsfiddle.net/Sg8JQ/ /* I'm including the minified script by Brandom Aaron here since I can't find ** a reliable host. Obviously, you can just link t

jQuery scroll to specific point with mouse wheel

Mike Lundina I found a JSFiddle that works great for using autoscroll between divs. Here is the script : http://jsfiddle.net/Sg8JQ/ /* I'm including the minified script by Brandom Aaron here since I can't find ** a reliable host. Obviously, you can just link t

How to click on a specific part of an element puppet

John Smith Let's say I have a 500px wide element called a "selector". For example, how would I click pixel 400? According to the puppeteer documentation, .hover() will hover in the middle of the element. When I test it with code like const selector = await pag

CSS - how to not scroll part of the page?

Mari Fahimi I see some sites that scroll partially, for example the page is divided into 2 columns.main and left. The main page is longer than the left page, when scrolling to the end the page stops, but the main page also scrolls. How can it be Paul Moretti H

How can I scroll a div when the mouse is down in jQuery?

Fred What I want to accomplish is to scroll the indicator in the red bar only when the mouse button is down (see image). Here is my jQuery code: var offset = 0; var mouseDown = false; $(document).ready(function() { $("#RedScroller").mousedown(function() {

How can I scroll a div when the mouse is down in jQuery?

Fred What I want to accomplish is to scroll the indicator in the red bar only when the mouse button is down (see image). Here is my jQuery code: var offset = 0; var mouseDown = false; $(document).ready(function() { $("#RedScroller").mousedown(function() {