Scroll event not triggering correctly?
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
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de HtmlUnit/htmlunit
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
Todos los issues de HtmlUnit/htmlunit
Issues similares
-
step.duration reflects only the last retry attempt (HelperStep.run() overwrites startTime)Posiblemente ocupada @mirao la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
codeceptjs/CodeceptJS#5774 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Status: Unconfirmed
Dificultad 1/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
AllTheMods/ATM10-Aeronautics#151 ·
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
feimacode/open-design-agent-kit#66 ·
Los mantenedores suelen responder en 1 día