简体   繁体   English

如何使用 Selenium Java 使用 Krypton 捕获屏幕截图

[英]How to capture a screenshot using Krypton using Selenium Java

文件问题 第 3 行的错误 当前代码 第 3 行的错误 I would like to seek help if there is a possible way / code to capture a screenshot under Krypton platform that uses JAVA selenium.如果有可能的方法/代码在使用JAVA selenium的Krypton平台下捕获屏幕截图,我想寻求帮助。 I'm having trouble in terms of it's standardization.我在标准化方面遇到了麻烦。 Thanks!谢谢!

var driver = new ChromeDriver()
driver.get("https://login.bws.birst.com/login.html/")
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE)
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"))

As per the screenshots there seems to be some discrepency with the imports/Classes.根据屏幕截图,导入/类似乎存在一些差异。 Further to keep things simpler create destination folder within the Project Scope eg the Screenshots directory below:为了让事情更简单,在项目范围内创建目标文件夹,例如下面的屏幕截图目录:

截图文件夹

To capture a screenshot using Java you can use the following solution:要使用Java捕获屏幕截图,您可以使用以下解决方案:

  • Code Block:代码块:

     package screenShot; import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class takesScreenshot { public static void main(String[] args) throws IOException { System.setProperty("webdriver.chrome.driver", "C:\\\\Utility\\\\BrowserDrivers\\\\chromedriver.exe"); ChromeOptions options = new ChromeOptions(); options.addArguments("start-maximized"); options.addArguments("disable-infobars"); options.addArguments("--disable-extensions"); WebDriver driver = new ChromeDriver(options); driver.get("https://login.bws.birst.com/login.html/"); new WebDriverWait(driver, 20).until(ExpectedConditions.titleContains("Birst")); File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(scrFile, new File(".\\\\Screenshots\\\\Mads_Cruz_screenshot.png")); } }
  • Captured Image:捕获的图像:

Mads_Cruz_screenshot

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Selenium 和 Java 在 Krypton 中检查属性 aria-disabled 的值是真还是假? - How do I check the value of the attribute aria-disabled as true or false in Krypton using Selenium and Java? 如何使用 selenium java 进行彩色截图 - how to take color screenshot using selenium java 如何使用Java在Selenium2中捕获屏幕截图,需要在最小化浏览器时捕获带有其父窗口(浏览器)的弹出窗口 - How to capture Screenshot in Selenium2 using Java, need to capture popup window with its parent window(Browser) when browser is minimized Selenium Webdriver-使用机器人捕获屏幕快照中的URL - Selenium Webdriver - Capture URL in screenshot using Robot 如何使用包装为Windows Service的Java程序捕获屏幕截图 - How to capture screenshot using a java program wrapped as windows service 如何使用 Java Selenium 抓取远程网站 - How to capture a remote website using Java Selenium 有没有办法使用Selenium(Java)在Appium中的Android屏幕上捕获特定elementID的屏幕截图? - Is there a way to capture the screenshot of specific elementID on Android screen in Appium using Selenium (Java)? 如何使用 Selenium 和 Java 获取完整网页的屏幕截图? - How to get screenshot of full webpage using Selenium and Java? 使用htmlunitdriver捕获屏幕截图? - Capture screenshot using htmlunitdriver? 使用Selenium 3.6截屏-Java-Webdriver - Taking Screenshot using Selenium 3.6 - Java - Webdriver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM