RSelenium 中的滚动页面 [英] Scrolling page in RSelenium

查看:20
本文介绍了RSelenium 中的滚动页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 RSelenium WebDriver 手动滚动到页面的底部(或顶部)?我有一个元素,只有当它在页面上可见时才可用.

How can I manually scroll to the bottom (or top) of a page with the RSelenium WebDriver? I have an element that only becomes available when it is visible on the page.

推荐答案

假设你有

library(RSelenium)
startServer()
remDr <- remoteDriver()
remDr$open()
remDr$setWindowSize(width = 800, height = 300)
remDr$navigate("https://www.r-project.org/about.html")

您可以像这样滚动到按钮:

You could scroll to the buttom like this:

webElem <- remDr$findElement("css", "body")
webElem$sendKeysToElement(list(key = "end"))

你可以像这样滚动到顶部:

And you could scroll to the top like this:

webElem$sendKeysToElement(list(key = "home"))

<小时>

如果您想向下滚动一点,请使用


And in case you want to scroll down just a bit, use

webElem$sendKeysToElement(list(key = "down_arrow"))

键名在selKeys中.

这篇关于RSelenium 中的滚动页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆