Can't get any screenshots with ScreenshotPrefix option enabled
Without this option I get screenshots but I want to set specific name for each, Even when I try to do it like this: FluentSettings.Current.ScreenshotPrefix = "test"; it doesn't work
What happens? Do the screenshots not get created anywhere or just not with the test prefix?
They don't get created anywhere
Is it posible to set screenshot prefix as a test method name? As I do for log output: Console.WriteLine(MethodBase.GetCurrentMethod().Name);
Decided to do like this. Failed test name is the screenshot name. Last link is also printed. I perform screenshot action on test failure (add this step to TearDown)
public DriverTearDown(IWebDriver driver)
{
if (TestContext.CurrentContext.Result.Status == TestStatus.Failed)
{
string screenshotName = Regex.Replace(TestContext.CurrentContext.Test.Name, "[^a-zA-Z0-9(),]", ""); //Remove invalid characters
string screenshotPath = AppDomain.CurrentDomain.BaseDirectory; //Get application path
const string screenshotExtention = ".jpeg"; //Set extention
driver.TakeScreenshot()
.SaveAsFile(screenshotName + screenshotExtention, ImageFormat.Jpeg);
throw new Exception(
" \nUrl was: " + driver.Url +
" \nScreenshot: " + screenshotPath +"\\"+ screenshotName + screenshotExtention);
}
}
Exception helps to see this info in html-report.