我正在尝试从R中的RSELENIUM中的硒复制scrollIntoView函数:Scroll Element into View with Selenium
我的问题是,要滚动显示的页面中的元素不会显示,并且remDr $ mouseMoveToLocation(webelem = element)在页面上不起作用。
使用类似的公共homeaway.com页面重现示例:
library(RSelenium)
remDr$navigate("https://www.homeaway.com/")
Sys.sleep(3)
inputgo <- remDr$findElement(using='xpath','//input[contains(@id,"destination")]')
inputgo$clearElement()
inputgo$sendKeysToElement(list("Seattle, Washington"))
Sys.sleep(2)
inputgo$sendKeysToElement(list(key="enter"))
butclick <- remDr$findElement(using='xpath','//button[@type="submit" and text()="Search"]')
butclick$clickElement()
尝试滚动div的第20个div子级[@ class =“ HitCollection”]:
###Attempted NOT FUNCTIONAL, I'm missing something here:
remDr$executeScript("arguments[0].scrollIntoView(true);", args=list(driver.getElementByXpath("//div[@class='HitCollection']/div[20]")
也在离家出走的页面上,remDr $ mouseMoveToLocation()不执行任何操作:
webelem <- remDr$findElement(using='xpath','//div[@class="HitCollection"]/div[20]')
###DOES NOTHING
remDr$mouseMoveToLocation(webElement=webelem)