如何使用 selenium 在模态中向下滚动

发布于 2025-01-16 00:56:16 字数 622 浏览 1 评论 0原文

在此处输入图像描述

我不知道如何向下滚动模式窗口。 我尝试了下面的方法,但是整个外部窗口的滚动向下,而不是模态窗口。

WebElement element = webDriver.findElement(By.xpath("//body/*[last()]"));
((JavascriptExecutor) webDriver).executeScript("arguments[0].scrollIntoView(true)", element);

我将附上该网站,但您必须尝试登录才能在模式窗口中查看作者列表

enter image description here

I don't know how to scroll down the modal window.
I tried the method below, but the scroll of the entire outer window goes down, not the modal window.

WebElement element = webDriver.findElement(By.xpath("//body/*[last()]"));
((JavascriptExecutor) webDriver).executeScript("arguments[0].scrollIntoView(true)", element);

I will attach the site, but you have to try to log in to check the list of authors in the modal window

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

几味少女 2025-01-23 00:56:16

如果模式位于 Iframe 中,请切换到 iFrame,然后尝试向下滚动

或使用下面的

方法 1

Actions act = new Actions(driver)
act.sendKeys(Keys.PAGE_DOWN).build().perform() 

方法 2

EventFiringWebDriver eventfiringWebDriver = new EventFiringWebDriver(driver);

        eventfiringWebDriver.executeScript("document.querySelector('.scroll-wrapper').scrollTop=5000")

If modal is in Iframe than, Switch to iFrame and then try to scroll down

or use the below

Method 1

Actions act = new Actions(driver)
act.sendKeys(Keys.PAGE_DOWN).build().perform() 

Method 2

EventFiringWebDriver eventfiringWebDriver = new EventFiringWebDriver(driver);

        eventfiringWebDriver.executeScript("document.querySelector('.scroll-wrapper').scrollTop=5000")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文