我试图从R中R selenium的selenium复制scrollIntoView函数:
Scroll Element into View with Selenium
我的问题是,我想要的页面上的元素在滚动到视图中之前不会出现,并且remDr$mouseMoveToLocation(webelem=element)在页面上不起作用。
使用类似的public复制示例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()
###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)