我正在使用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
我不知道为什么我会得到这个错误。我会感激你的帮助。
答案 0 :(得分:1)
如果您不使用require(RSelenium)
rSel <- rsDriver()
remDr <- rSel$client
enlace<-"http://www.la14.com"
remDr$navigate(enlace)
rSel$server$stop()
,则不会启动任何RSelenium服务器。我可以导航到该网站并加载页面:
class Thing(Document):
name = StringField()
age = IntField(unique_with='name')