Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Scroll event not triggering correctly?

Abierto
#657 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
html, java, javascript
Área
testing

Línea de trabajo

Start by reproducing the supplied JUnit test with both ChromeDriver and HtmlUnitDriver; the issue does not name repository files or existing tests to use. Investigate how HtmlUnit handles scrollIntoView and IntersectionObserver, then add a regression test for the behavior. Done means the observer callback increments the count as expected in HtmlUnit, while the Chrome comparison still passes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

I've ran into a case where triggering javascript scrollintoView has no effect, not triggering an event that is supposed to dynamically load the next page of data.

Here is a basic test case:

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;

public class ScrollTest {

    public static final String PAGE;

    static {
        try {
            PAGE = Files.readString(Path.of(ScrollTest.class.getClassLoader().getResource("testPage1.html").toURI()));
        } catch (IOException | URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }

    private static final HtmlUnitDriver huDriver = new HtmlUnitDriver(true);
    private static final WebDriver chromeDriver = new ChromeDriver();

    @AfterAll
    static void closeAll(){
        huDriver.close();
        chromeDriver.close();
    }

    @Test
    void givenPageWithTable_whenScrollTo_TriggerEvent(){
        runTest(chromeDriver);
        runTest(huDriver);
    }

    private static void runTest(WebDriver driver) {
        driver.get(PAGE);
        ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView()", driver.findElement(By.id("last")));
        Assertions.assertEquals(1L,
                ((JavascriptExecutor) driver).executeScript("return count"));
    }

}

and here is the html file I used for testing, feel free to add more table rows if needed

data:text/html,
<table>
    <tr>row</tr>
    <br>
    <tr id="last"></tr>
</table>
<script>
    var count = 0;
    const observer = new IntersectionObserver((entries) => { 
    entries.forEach((entry) => {
        console.log("triggered");
        count++;
    })
}); 

observer.observe(document.getElementById("last"));
</script>

The results are incosistent:

org.opentest4j.AssertionFailedError: 
Expected :1
Actual   :0
<Click to see difference>

at ScrollTest.runTest(ScrollTest.java:45)
at ScrollTest.givenPageWithTable_whenScrollTo_TriggerEvent(ScrollTest.java:39)

...removed rest of generic stack trace...	
Lenguaje dominante
JavaScript
Estrellas
952
Forks
183
Merge medio
2 d 1 h
PR fusionados (30 d)
1

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de HtmlUnit/htmlunit

Todos los issues de HtmlUnit/htmlunit

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.