我正在执行一个selenium-cucumber框架,我遇到了以下问题:`
public class SteamAuthenticationMiddleware : OpenIdConnectMiddleware
{
public SteamAuthenticationMiddleware(
RequestDelegate next,
IDataProtectionProvider dataProtectionProvider,
ILoggerFactory loggerFactory,
UrlEncoder encoder,
IServiceProvider services,
IOptions<SharedAuthenticationOptions> sharedOptions,
IOptions<OpenIdConnectOptions> options,
HtmlEncoder htmlEncoder) :
base(
next,
dataProtectionProvider,
loggerFactory,
encoder,
services,
sharedOptions,
options,
htmlEncoder)
{
}
protected override AuthenticationHandler<OpenIdConnectOptions> CreateHandler() => new SteamAuthenticationHandler();
}
请让我知道这个问题。这与lo RAM有关吗?
答案 0 :(得分:0)
@After public void snapShotOnFail(Scenario scenario) throws Throwable {
try {
if (scenario.isFailed()) {
final byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
}
} catch (WebDriverException somePlatformsDontSupportScreenshots) {
System.err.println(somePlatformsDontSupportScreenshots.getMessage());
}
}
答案 1 :(得分:0)
尝试此操作并根据您的需要进行修改
@After
public void shutDown(Scenario scenario){
if (scenario.isFailed()) {
final byte[] screenshot = ((TakesScreenshot) Driver.getDriver()).getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
}
Driver.closeDriver();
}
答案 2 :(得分:0)
在截取屏幕截图时尝试尝试此错误。并且它可以在Cucumber范围报告中添加失败的测试用例的屏幕截图。
public void forAfterScen(Scenario scenario) throws IOException
{
if (scenario.isFailed()) {
String screenshotName = scenario.getName().replaceAll(" ", "_");
try {
TakesScreenshot ts = (TakesScreenshot) driver;
File sourcePath = ts.getScreenshotAs(OutputType.FILE);
File destinationPath = new File(System.getProperty("user.dir") + "\\Report\\" + screenshotName+".png");
Files.copy(sourcePath, destinationPath);
Reporter.addScreenCaptureFromPath(destinationPath.toString());
Reporter.addScenarioLog(screenshotName);
} catch (IOException e) {
}
}
}