简体   繁体   English

在Chrome中使用sendKeysToElement时出现RSelenium错误

[英]RSelenium error when using sendKeysToElement in Chrome

I am trying to use RSelenium to remotely interact with a webpage in Chrome: 我正在尝试使用RSelenium与Chrome中的网页进行远程交互:

remDr <- remoteDriver(browserName = "chrome")
remDr$open()
remDr$navigate("http://database.globalreporting.org/search")
textBox <- remDr$findElement("id", "search-report-field")
textBox$sendKeysToElement("Company Name")

Specifically, I want to be able to send keystrokes to the textbox on this page labeled "Search by organization name" (the textbox id is "search-report-field"). 具体来说,我希望能够在此页面上标记为“按组织名称搜索”(文本框ID为“search-report-field”)的文本框中发送击键。 I am able to perform various actions on the element (highlight, click, etc...), but sendKeysToElement throws the following error: 我能够对元素执行各种操作(突出显示,单击等等),但sendKeysToElement会抛出以下错误:

Error:   Summary: UnknownError
         Detail: An unknown server-side error occurred while processing the command.
         class: java.lang.ClassCastException

Any idea what might be causing the problem and how to fix it? 知道可能导致问题的原因以及如何解决问题?

The keys need to be given as a list for example: 密钥需要作为列表给出,例如:

textBox$sendKeysToElement(list("some Text", key = "enter"))

For your example: 对于你的例子:

library(RSelenium)
# running
#  docker run -d -p 5901:5900 -p 127.0.0.1:4444:4444 selenium/standalone-chrome-debug:2.53.0
remDr <- remoteDriver(browserName = "chrome")
remDr$open()
remDr$navigate("http://database.globalreporting.org/search")
textBox <- remDr$findElement("id", "search-report-field")
textBox$sendKeysToElement(list("Company Name"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM