ファイルタイプがfileのjavaメソッドを作成しました。このメソッドは、Ashotを使用してスクリーンショットを取得し、Screenshotオブジェクトに格納します。そのスクリーンショットオブジェクトをファイルオブジェクトに変換して、ファイルオブジェクトを返す必要があります。スクリーンショットオブジェクトをAshotセレニウムのファイルオブジェクトに変換する方法
public static File grabScreenshot() {
try {
Thread.sleep(Integer.parseInt(Property.getProperty("screenshotDelay")));
} catch (InterruptedException e) {
e.printStackTrace();
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
File screenshot=null; //creating null file object to return
Screenshot screenshot1 = new AShot().shootingStrategy(new ViewportPastingStrategy(1000)).takeScreenshot(driver());
//Here I have to typecast the screenshot1 to file type so that I can return
return screenshot;
}
はあなたが私たちあなたのコード表示することができますトリックを行う必要がありますか? –