【问题标题】:RSelenium doesn't open web pageRSelenium 无法打开网页
【发布时间】:2017-06-05 17:49:52
【问题描述】:

我正在使用 RSelenium 访问 JSON 网页。我已经将我的机器配置为打开谷歌浏览器,但我在浏览我的网页时遇到了问题。我的代码如下:

> require(RSelenium)
Loading required package: RSelenium
> remDr <- remoteDriver(browserName = "chrome")
> remDr$open()
[1] "Connecting to remote server"
$applicationCacheEnabled
[1] FALSE

$rotatable
[1] FALSE

$mobileEmulationEnabled
[1] FALSE

$networkConnectionEnabled
[1] TRUE

$chrome
$chrome$userDataDir
[1] "C:\\Users\\fjchauxg\\AppData\\Local\\Temp\\scoped_dir6336_25181"


$takesHeapSnapshot
[1] TRUE

$databaseEnabled
[1] FALSE

$handlesAlerts
[1] TRUE

$hasTouchScreen
[1] TRUE

$version
[1] "58.0.3029.110"

$platform
[1] "XP"

$browserConnectionEnabled
[1] FALSE

$nativeEvents
[1] TRUE

$acceptSslCerts
[1] TRUE

$webdriver.remote.sessionid
[1] "f3bb1468-58e9-427d-82e1-c11c2beedcfe"

$locationContextEnabled
[1] TRUE

$webStorageEnabled
[1] TRUE

$browserName
[1] "chrome"

$takesScreenshot
[1] TRUE

$javascriptEnabled
[1] TRUE

$cssSelectorsEnabled
[1] TRUE

$id
[1] "f3bb1468-58e9-427d-82e1-c11c2beedcfe"

> enlace<-"http://www.la14.com"
> remDr$navigate(enlace)

Selenium message:unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"7836.1","isDefault":true},"id":1,"name":"","origin":"://"}
  (Session info: chrome=58.0.3029.110)
  (Driver info: chromedriver=2.11.298604 (75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 8 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'FJCHAUXG', ip: '172.16.120.129', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=C:\Users\fjchauxg\AppData\Local\Temp\scoped_dir6336_25181}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=58.0.3029.110, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: cf2489a4c083409ed6072ed2f8b9eaf7

Error:   Summary: UnknownError
     Detail: An unknown server-side error occurred while processing the command.
     class: org.openqa.selenium.WebDriverException
     Further Details: run errorDetails method

在 chrome 中,我收到以下消息:

这是指 Chrome 中的扩展程序。我点击取消并再次运行:

> remDr$navigate(enlace)

Selenium message:java.net.SocketException: Connection reset
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'FJCHAUXG', ip: '172.16.120.129', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131'
Driver info: driver.version: EventFiringWebDriver

Error:   Summary: UnknownError
     Detail: An unknown server-side error occurred while processing the command.
     class: org.openqa.selenium.WebDriverException
     Further Details: run errorDetails method

最后,我注意到我无法关闭 chrome:

> remDr$close()

Selenium message:Connection refused: connect

    Error:   Summary: UnknownError
         Detail: An unknown server-side error occurred while processing the command.
         class: java.net.ConnectException
         Further Details: run errorDetails method

我不知道为什么会出现此错误。我会很感激你的帮助。

【问题讨论】:

    标签: javascript google-chrome rselenium


    【解决方案1】:

    如果您不使用rsDriver(),则不会启动任何RSelenium 服务器。我可以导航到网站并加载页面:

    require(RSelenium)
    rSel <- rsDriver()
    remDr <- rSel$client
    
    enlace<-"http://www.la14.com"
    remDr$navigate(enlace)
    rSel$server$stop()
    

    【讨论】:

    • ConCave 您的解决方案不起作用。我在检查 geckodriver 版本时获得了Error in open.connection(con, "rb") : Couldn't connect to server。也就是说,它不会下载 geckodriver。
    • 您使用的是什么版本的 R 和 Rselenium?
    • R 3.4.0 和 R Studio 1.0.143。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-16
    • 2015-01-20
    • 2021-09-25
    • 1970-01-01
    相关资源
    最近更新 更多