Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Scroll event not triggering correctly?

Đang mở
#657 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
html, java, javascript
Lĩnh vực
testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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...	
Ngôn ngữ chính
JavaScript
Star
952
Fork
183
Merge trung bình
2 ngày 1 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của HtmlUnit/htmlunit

Tất cả issue của HtmlUnit/htmlunit

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.