Selenium 如何调用CaptureShreenshot方法来报告错误?
我下面的代码只显示了5个工具提示列表,实际上有6个工具提示。System.out.println(contactTooltipList.size())给出大小6Selenium 如何调用CaptureShreenshot方法来报告错误?,selenium,Selenium,我下面的代码只显示了5个工具提示列表,实际上有6个工具提示。System.out.println(contactTooltipList.size())给出大小6 public void clickOnContacts() { log.info("Clicked on 'Contacts' tab option and Tooltips are: "); System.out.println(contactTooltipList.size());
public void clickOnContacts()
{
log.info("Clicked on 'Contacts' tab option and Tooltips are: ");
System.out.println(contactTooltipList.size());
contactDropDown.click();
Iterator<WebElement> itr= contactTooltipList.iterator();
while(itr.hasNext()) {
String toolTips = itr.next().getText();
toolTips=toolTips.replaceAll("\n", " ");
System.out.println(toolTips);
}
System.out.println("\n");
}
我想通过截图报告错误,因为显示的工具提示与大小不符。
如何调用captureScreenshot方法?或者我如何报告它是一个bug?在Java中,您可以截图如下:
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
// add the above imports
File screenshotFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
现在您已经存储了屏幕快照文件
,您可以对其执行任何需要的操作,例如将其保存到您的系统中:
FileUtils.copyFile(screenshotFile, new File("C:/Path/where/to/save/screenshot));
FileUtils.copyFile(screenshotFile, new File("C:/Path/where/to/save/screenshot));