简体   繁体   中英

RSelenium sendKeysToActiveElement() function throws unknown command error

I'm trying to press enter key using the RSelenium's sendKeysToActiveElement() function but it's throwing the following error.

remDr$sendKeysToActiveElement(list("", key="back"))

It throws the following error:

Selenium message:sendKeysToActiveElement
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'DEV-WINDOWS', ip: '192.168.1.18', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: driver.version: unknown

Error:   Summary: UnknownCommand
     Detail: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.
     Further Details: run errorDetails method

This is what errorDetails() shows :

remDr$errorDetails()
$stacktrace
[1] "org.openqa.selenium.UnsupportedCommandException: sendKeysToActiveElement\nBuild info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'\nSystem info: host: 'DEV-WINDOWS', ip: '192.168.1.18', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'\nDriver info: driver.version: unknown\r\n\tat org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:218)\r\n\tat org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:117)\r\n\tat org.openqa.selenium.grid.session.remote.ProtocolConverter.handle(ProtocolConverter.java:83)\r\n\tat org.openqa.selenium.grid.session.remote.RemoteSession.execute(RemoteSession.java:129)\r\n\tat org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0(WebDriverServlet.java:235)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\r\n\tat java.lang.Thread.run(Thread.java:748)\r\n"

$stackTrace
$stackTrace[[1]]
$stackTrace[[1]]$fileName
[1] "AbstractHttpCommandCodec.java"

$stackTrace[[1]]$methodName
[1] "encode"

$stackTrace[[1]]$className
[1] "org.openqa.selenium.remote.http.AbstractHttpCommandCodec"

$stackTrace[[1]]$lineNumber
[1] 218


$stackTrace[[2]]
$stackTrace[[2]]$fileName
[1] "AbstractHttpCommandCodec.java"

$stackTrace[[2]]$methodName
[1] "encode"

$stackTrace[[2]]$className
[1] "org.openqa.selenium.remote.http.AbstractHttpCommandCodec"

$stackTrace[[2]]$lineNumber
[1] 117


$stackTrace[[3]]
$stackTrace[[3]]$fileName
[1] "ProtocolConverter.java"

$stackTrace[[3]]$methodName
[1] "handle"

$stackTrace[[3]]$className
[1] "org.openqa.selenium.grid.session.remote.ProtocolConverter"

$stackTrace[[3]]$lineNumber
[1] 83


$stackTrace[[4]]
$stackTrace[[4]]$fileName
[1] "RemoteSession.java"

$stackTrace[[4]]$methodName
[1] "execute"

$stackTrace[[4]]$className
[1] "org.openqa.selenium.grid.session.remote.RemoteSession"

$stackTrace[[4]]$lineNumber
[1] 129


$stackTrace[[5]]
$stackTrace[[5]]$fileName
[1] "WebDriverServlet.java"

$stackTrace[[5]]$methodName
[1] "lambda$handle$0"

$stackTrace[[5]]$className
[1] "org.openqa.selenium.remote.server.WebDriverServlet"

$stackTrace[[5]]$lineNumber
[1] 235


$stackTrace[[6]]
$stackTrace[[6]]$fileName
[1] "Executors.java"

$stackTrace[[6]]$methodName
[1] "call"

$stackTrace[[6]]$className
[1] "java.util.concurrent.Executors$RunnableAdapter"

$stackTrace[[6]]$lineNumber
[1] 511


$stackTrace[[7]]
$stackTrace[[7]]$fileName
[1] "FutureTask.java"

$stackTrace[[7]]$methodName
[1] "run"

$stackTrace[[7]]$className
[1] "java.util.concurrent.FutureTask"

$stackTrace[[7]]$lineNumber
[1] 266


$stackTrace[[8]]
$stackTrace[[8]]$fileName
[1] "ThreadPoolExecutor.java"

$stackTrace[[8]]$methodName
[1] "runWorker"

$stackTrace[[8]]$className
[1] "java.util.concurrent.ThreadPoolExecutor"

$stackTrace[[8]]$lineNumber
[1] 1149


$stackTrace[[9]]
$stackTrace[[9]]$fileName
[1] "ThreadPoolExecutor.java"

$stackTrace[[9]]$methodName
[1] "run"

$stackTrace[[9]]$className
[1] "java.util.concurrent.ThreadPoolExecutor$Worker"

$stackTrace[[9]]$lineNumber
[1] 624


$stackTrace[[10]]
$stackTrace[[10]]$fileName
[1] "Thread.java"

$stackTrace[[10]]$methodName
[1] "run"

$stackTrace[[10]]$className
[1] "java.lang.Thread"

$stackTrace[[10]]$lineNumber
[1] 748


$message
[1] "sendKeysToActiveElement\nBuild info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'\nSystem info: host: 'DEV-WINDOWS', ip: '192.168.1.18', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'\nDriver info: driver.version: unknown"

$error
[1] "unknown command"

sessionInfo() shows following:

> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_India.1252  LC_CTYPE=English_India.1252   
[3] LC_MONETARY=English_India.1252 LC_NUMERIC=C                  
[5] LC_TIME=English_India.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] knitr_1.28        XML_3.99-0.3      RSelenium_1.7.7  
[4] animint2_2020.3.2 testthat_2.3.2   

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6     compiler_4.0.0   plyr_1.8.6      
 [4] bitops_1.0-6     tools_4.0.0      pkgload_1.1.0   
 [7] digest_0.6.25    jsonlite_1.6.1   evaluate_0.14   
[10] lifecycle_0.2.0  gtable_0.3.0     rlang_0.4.6     
[13] cli_2.0.2        rstudioapi_0.11  curl_4.3        
[16] yaml_2.2.1       xfun_0.14        binman_0.1.1    
[19] stringr_1.4.0    withr_2.2.0      httr_1.4.1      
[22] xml2_1.3.2       desc_1.2.0       askpass_1.1     
[25] caTools_1.18.0   rappdirs_0.3.1   rprojroot_1.3-2 
[28] grid_4.0.0       glue_1.4.1       R6_2.4.1        
[31] processx_3.4.2   fansi_0.4.1      rmarkdown_2.2   
[34] RJSONIO_1.3-1.4  farver_2.0.3     semver_0.2.0    
[37] magrittr_1.5     backports_1.1.7  scales_1.1.1    
[40] ps_1.3.3         htmltools_0.4.0  assertthat_0.2.1
[43] colorspace_1.4-1 labeling_0.3     stringi_1.4.6   
[46] openssl_1.4.1    munsell_0.5.0    crayon_1.3.4    
[49] wdman_0.2.5

Here's what RSelenium documentation says:

This is a set of R Bindings for Selenium 2.0 Remote WebDriver, which you can download from http://selenium-release.storage.googleapis.com/index.html . This binding will not work with the 1.0 version of Selenium.

Due do major changes in selenium v3, this function didn't work.

I was using the wrong version of selenium. I used v3 instead of v2.

Changing the selenium version solved the issue.

I ran into the same issue, and @lazycipher suggests, downgrading the selenium version helped. I did this by:

  1. Go to http://selenium-release.storage.googleapis.com/index.html
  2. Navigate to the 2.53 folder
  3. Download selenium-server-standalone-2.53.1.jar
  4. Move the jar file to a folder in the following location:
    • Linux: /home/[user]/.local/share/binman_seleniumserver/generic/2.53.1
    • Windows: C:\Users\[user]\AppData\Local\binman\binman_seleniumserver\generic\2.53.1\
    • MACOSX: /Users/admin/Library/Application\Support/binman_seleniumserver/generic/2.53.1/
  5. Check whether the downloaded version is listed using binman::list_versions("seleniumserver")
  6. Run RSelenium::rsDriver() with the version = '2.53.1' argument

It turns out, when RSelenium::rsDriver() accesses the selenium version, it refers to the binman package to direct it to the correct selenium jar file. If you place the jar file in the right folder, it'll be detected by binman and, consequently, by RSelenium .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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