1
Firefoxのscreenshot --fullpage
コマンドをSeleniumのJavaスクリプトの中から実行したいと思います。FirefoxデベロッパーコンソールコマンドをSeleniumから実行するには?
コマンドがTake a full page screenshot with Firefox
に文書化され、それが可能ですか?
Firefoxのscreenshot --fullpage
コマンドをSeleniumのJavaスクリプトの中から実行したいと思います。FirefoxデベロッパーコンソールコマンドをSeleniumから実行するには?
コマンドがTake a full page screenshot with Firefox
に文書化され、それが可能ですか?
Javaコード内からスクリーンショットを撮ることができます。この回答者:https://stackoverflow.com/a/3423347/8020699
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
This guyページ全体のスクリーンショットを取るためにaShotというライブラリを使用することを提案しています。 aShot jarへのリンクは次のとおりです。彼が提供するコードは次のとおりです。
import java.io.File;
import javax.imageio.ImageIO;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.shooting.ShootingStrategies;
public class FullPageScreenshot {
public static void main(String args[]) throws Exception{
//Modify the path of the GeckoDriver in the below step based on your local system path
System.setProperty("webdriver.gecko.driver","D://Selenium Environment//Drivers//geckodriver.exe");
// Instantiation of driver object. To launch Firefox browser
WebDriver driver = new FirefoxDriver();
// To oepn URL "http://softwaretestingmaterial.com"
driver.get("http://www.softwaretestingmaterial.com");
Thread.sleep(2000);
Screenshot fpScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
ImageIO.write(fpScreenshot.getImage(),"PNG",new File("D:///FullPageScreenshot.png"));
}
}
@AlexRこのaShotライブラリはあなたのために機能しますか? – TitusLucretius
しかし、 'Not_in_(Pythonで許可されています)'の 'Java'。ありがとう – DebanjanB
Firefoxコンソールの組み込みの 'screenshot --fullpage'コマンドと比較するとaShotは少し信頼できません(いくつかのページにはまってしまいます)。 –