2017-06-05 66 views
0

我正在與RSelenium一起訪問JSON網頁。我已經配置我的機器來打開谷歌瀏覽器,但我有問題瀏覽我的網頁。我的代碼如下:RSelenium不打開網頁

> 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中,我得到了以下信息:

enter image description here

這是值得refered在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 

,我注意到,我無法靠近鍍鉻:

> 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 

我不知道爲什麼我獲得這個錯誤。我會感激你的幫助。

回答

1

如果您不使用rsDriver(),則不會啓動RSelenium服務器。我可以導航到網站並加載頁面:

require(RSelenium) 
rSel <- rsDriver() 
remDr <- rSel$client 

enlace<-"http://www.la14.com" 
remDr$navigate(enlace) 
rSel$server$stop() 
+0

ConCave您的解決方案無法正常工作。我在open.connection(con,「rb」)中獲得''錯誤:在檢查geckodriver版本時無法連接到服務器'。也就是說,它不下載geckodriver。 – fcochaux

+0

您使用的是R和Rselenium版本? –

+0

R 3.4.0和R Studio 1.0.143。 – fcochaux