Rselenium函数内部的驱动程序方法

时间:2017-04-02 10:02:35

标签: r rselenium

我试图在函数中使用sendKeysToElement()之类的方法。我的问题与this类似,但即使我将引用远程驱动器作为函数参数传递,我仍然会收到错误。在没有函数时执行此代码没有问题。

question <- "Which hormone concentrations are altered in patients with the Allan Herndon Dudley syndrome?"

searchMM <- function(x, remDr){
  remDr$findElement("css","textarea")$clearElement()
  remDr$findElement("css","textarea")$sendKeysToElement(list(x))
  remDr$findElement("css", "#note > input[type='button']:nth-child(12)")$clickElement()
  concept <- remDr$findElement("css","table:nth-child(31) pre")$getElementText()
  remDr$goBack()
  concept <- unlist(concept)
  test <- unlist(str_split(concept, "\n"))
}

searchMM(x=question, remDr=remDr)
test

运行此功能后,当我尝试查看test中的内容时,我得到Error: object 'test' not found。就此而言,concept也不存在。我做错了什么?

1 个答案:

答案 0 :(得分:1)

Country Name    Year    Thousand of units
Belgium         2005    1,044,074
Belgium         2006    1,092,214
Belgium         2007    1,079,477
Bulgaria        2005    25,660
Bulgaria        2006    34,310
Bulgaria        2007    60,228
Czech Republic  2005    261,999
Czech Republic  2006    262,207
Czech Republic  2007    254,053