Scroll event not triggering correctly?
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 45/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- html, java, javascript
- Domaine
- testing
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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...
- Langage dominant
- JavaScript
- Étoiles
- 952
- Forks
- 183
- Merge moyen
- 2 j 1 h
- PR mergées (30 j)
- 1
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de HtmlUnit/htmlunit
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
Toutes les issues de HtmlUnit/htmlunit
Issues similaires
-
good first issue
Difficulté 2/5 3-5 jours Accessibilité débutants 62/100
paipai1999/POS-system#3 ·
-
good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
r-afael/better-yt-recommendations#36 ·
Les mainteneurs répondent en général sous 1 jour
-
needs-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
microsoft/playwright#43875 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
cli good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
Run the dependency drift checkPeut-être pris @spaceninja l’a pris aujourd’hui. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
cloudfour/stylelint-config-cloudfour#683 ·
Les mainteneurs répondent en général sous 1 jour