2016-10-17 27 views
2

以下のコードを記述して、Webページのスクリーンショット全体をJavaスクリプトを使用してキャプチャしました。プロパティ "H"にアクセスする権限が拒否されました

私が使用している: Firefoxのバージョン: 49.0.1 クロームバージョン: 54.0.2840.59メートル セレンバージョン:3.0.0 OS: Win10 64ビット のJavaを: 1.8

import java.io.File; 
import java.io.IOException; 

import org.apache.commons.io.FileUtils; 
import org.openqa.selenium.JavascriptExecutor; 
import org.openqa.selenium.OutputType; 
import org.openqa.selenium.TakesScreenshot; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 

public class ScreenCapture { 

    public static void main(String[] args) throws IOException { 
     System.setProperty("webdriver.gecko.driver","C:\\Eclipse\\Drivers\\geckodriver.exe"); 
     WebDriver driver = new FirefoxDriver(); 
     driver.get("https://www.flipkart.com/"); 
     driver.manage().window().maximize(); 
     JavascriptExecutor js = (JavascriptExecutor) driver; 
     js.executeScript("window.scrollTo(0, document.body.scrollHeight)"); 
     File capture = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); 
     FileUtils.copyFile(capture, new File("C:\\Users\\Vishvambruth JT\\Desktop\\FlipKart.jpg")); 
    } 
} 

ウェブページがスクロールします下のエラーでコードが突然停止します。助けてください。

1476679740598 geckodriver INFO Listening on 127.0.0.1:38310 
Oct 16, 2016 11:49:00 PM org.openqa.selenium.remote.ProtocolHandshake createSession 
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end 
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies). 
log4j:WARN Please initialize the log4j system properly. 
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 
1476679741083 mozprofile::profile INFO Using profile path C:\Users\VISHVA~1\AppData\Local\Temp\rust_mozprofile.h4P3qq7Ekmrz 
1476679741083 geckodriver::marionette INFO Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe 
1476679741083 geckodriver::marionette INFO Connecting to Marionette on localhost:50064 
1476679742059 Marionette INFO Listening on port 50064 
1476679743366 Marionette INFO startBrowser 6f833edf-0ff4-4f1f-869c-1de62f8626a9 
Oct 16, 2016 11:49:03 PM org.openqa.selenium.remote.ProtocolHandshake createSession 
INFO: Detected dialect: W3C 
Exception in thread "main" org.openqa.selenium.WebDriverException: Permission denied to access property "H" 
Build info: version: 'unknown', revision: '350cf60', time: '2016-10-13 10:43:56 -0700' 
System info: host: 'LAPTOP-JUUNTJIC', ip: '10.0.0.112', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101' 
Driver info: org.openqa.selenium.firefox.FirefoxDriver 
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20160922113459, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=9960, browserVersion=49.0.1, platformVersion=10.0, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt, device=desktop}] 
Session ID: 6f833edf-0ff4-4f1f-869c-1de62f8626a9 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127) 
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93) 
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42) 
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163) 
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) 
    at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:537) 
    at ScreenCapture.main(ScreenCapture.java:19) 
+0

geckodriver.exeの代わりにwires.exeを使用し、geckodriver –

+0

@ PotnuruRaviの代わりにワイヤとしてローカルシステム名にgeckodriver.exeファイルの名前をwires.exeに変更し、コードを次のように変更します。System .setProperty( "webdriver.wires.driver"、 "C:\\ Eclipse \\ Drivers \\ wires.exe"); –

+0

と同じですが、ファイルをwires.exeとして保存しないでください。 –

答えて

0

Selenium Web Driver 3.0.1で同じエラーが発生しました。 バージョン2.53.1に切り替えると問題が解消されました。

0

私もこの問題を抱えており、いくつかの研究の後で、私はそれがセレンの問題ではないと言うことができます。 geckoドライバで問題です。あなたはクロムでそれを実行することができ、それは正常に動作します。

0

Firefox Nightへのアップデートだけで動作します。

Firefox Nightはhttps://www.mozilla.org/en-US/firefox/channel/desktop/(Betaとラベルされたもの)にあります。

最新のWebdriverバージョンを最新のFirefox Nightバージョンで使用することをお勧めします(開発とコードの問題のすべての努力と努力はその同期に焦点を当てています)より新しい最終的なユーザーシナリオをよりよくカバーするために)。

関連する問題