如何使用Selenium Hub,Node和Remote Webdriver捕获图像并将其附加到Cucumber Reports(Jenkins)? [英] How to capture images and attach them to Cucumber Reports (Jenkins) using Selenium Hub, Node and Remote Webdriver?
问题描述
当前,我正在使用Ubuntu实例在云中触发自动化测试.
Currently I'm triggering my automation tests in the cloud using a Ubuntu instance.
Ubuntu实例有一个正在运行的Jenkins实例,还有Selenium Hub和Node.似乎屏幕截图图像未保存在ubuntu系统上的builds \ 3 \ cucumber-html-reports \ embedddings中,但是在Windows系统上不存在此问题.
The Ubuntu instance has a Jenkins instance running and also Selenium Hub and Node. It seems the screenshot images dont get saved within the builds\3\cucumber-html-reports\embeddings on a ubuntu system however on a windows system this issue does not exist.
我目前添加了以下逻辑来捕获图像并将其附加到Jenkins Cucumber报告中,但是当前图像未附加到报告中:
I have currently added the below logic to capture and attach images to the Jenkins Cucumber reports however currently the images are not getting attached to the reports:
@After
public void after(Scenario scenario) {
if (scenario.isFailed()) {
try {
WebDriver augmentedDriver = new Augmenter().augment(getDriver());
byte[] s = ((TakesScreenshot)augmentedDriver).getScreenshotAs(OutputType.BYTES);
scenario.embed(s, "image/png");
示例报告(由詹金斯生成),请注意,在本地运行测试时,图像已保存并附加到报告中.
Example Report (Generated in Jenkins), please note the images are getting saved and attached to the reports when running the tests locally.
推荐答案
我没有关于ubuntu问题的直接答案.但是,请尝试将捕获图像的路径作为html链接添加到您的黄瓜报告中.
I do not have direct answer for ubuntu problem. But, try adding path of captured images to your cucumber report as html links.
@After
public void after(Scenario scenario){
if (scenario.isFailed()) {
try {
WebDriver augmentedDriver = new Augmenter().augment(getDriver());
File path = ((TakesScreenshot)augmentedDriver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(path,new File(localRepoPath));
String html = "<html><body><a href=\">" + localRepoPath + "\"> screenshot </a></body></html>";
scenario.embed(html.getBytes(), "text/html");
}catch(Exception e){
// Do Something
}
}
}
这篇关于如何使用Selenium Hub,Node和Remote Webdriver捕获图像并将其附加到Cucumber Reports(Jenkins)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!