2016-08-09 4 views
0

がかかりますwebdriverを:セレン - Firefoxの唯一の私は、次のコードを読んだことから、一部のスクリーンショット

File s = ((TakesScreenshot)driver_).getScreenshotAs(OutputType.FILE); 
    try { 
     FileUtils.copyFile(s,new File("C:\\scr.png")); 
    } catch (IOException exception) { 
     exception.printStackTrace(); 
    } 

は、ページ全体のスクリーンショットを取る必要があります。しかし、私の場合は、現在ブラウザウィンドウに表示されているもののスクリーンショットしか撮れません。これは予想された動作ですか、何かコード内で間違っていましたか?

答えて

0

はい、これはFirefoxからの動作です。 あなたはまだいくつかのコンテンツを欠場することができますが、あなたは完全なページのスクリーンショットを撮りたい場合は、

executor = (JavascriptExecutor)driver.getDriver(); 
executor.executeScript(
     "document.body.style.zoom= 
      (top.window.screen.height-70)/ 
      Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);"); 
File scrFile = ((TakesScreenshot)driver.getDriver()).getScreenshotAs(OutputType.FILE); 

表示領域にコンテンツ全体をズームアウトするために、このようなものを使用することができますそれは、目に見える領域にすべてのコンテンツを持参しようとします最下部から

関連する問題