Take Screenshot on Automation tests for build status notifications

pull/1689/head
Qstick 4 years ago
parent c08c516ff7
commit c00cbb8276

@ -707,6 +707,16 @@ stages:
chmod a+x ${TESTSFOLDER}/test.sh
${TESTSFOLDER}/test.sh ${OSNAME} Automation Test
displayName: Run Automation Tests
- task: CopyFiles@2
displayName: 'Copy Screenshot to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: |
**/*_test_screenshot.png
TargetFolder: '$(Build.ArtifactStagingDirectory)/screenshots'
- publish: $(Build.ArtifactStagingDirectory)/screenshots
artifact: '$(osName)AutomationScreenshots'
displayName: Publish Screenshot Bundle
- task: PublishTestResults@2
inputs:
testResultsFormat: 'NUnit'
@ -853,8 +863,15 @@ stages:
- job:
displayName: Discord Notification
pool:
vmImage: 'ubuntu-18.04'
vmImage: 'windows-2019'
steps:
- task: DownloadPipelineArtifact@2
continueOnError: true
displayName: Download Screenshot Artifact
inputs:
buildType: 'current'
artifactName: 'WindowsAutomationScreenshots'
targetPath: $(Build.SourcesDirectory)
- checkout: none
- powershell: |
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/Servarr/AzureDiscordNotify/master/DiscordNotify.ps1'))

@ -42,6 +42,8 @@ namespace NzbDrone.Automation.Test
// Timeout as windows automation tests seem to take alot longer to get going
driver = new ChromeDriver(service, options, new TimeSpan(0, 3, 0));
driver.Manage().Window.Size = new System.Drawing.Size(1920, 1080);
_runner = new NzbDroneRunner(LogManager.GetCurrentClassLogger());
_runner.KillAll();
_runner.Start();
@ -62,6 +64,19 @@ namespace NzbDrone.Automation.Test
.Select(e => e.Text);
}
protected void TakeScreenshot(string name)
{
try
{
Screenshot image = ((ITakesScreenshot)driver).GetScreenshot();
image.SaveAsFile($"./{name}_test_screenshot.png", ScreenshotImageFormat.Png);
}
catch (Exception ex)
{
Console.WriteLine($"Failed to save screenshot {name}, {ex.Message}");
}
}
[OneTimeTearDown]
public void SmokeTestTearDown()
{

@ -1,3 +1,4 @@
using System.Reflection;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Automation.Test.PageModel;
@ -21,6 +22,10 @@ namespace NzbDrone.Automation.Test
{
_page.LibraryNavIcon.Click();
_page.WaitForNoSpinner();
var imageName = MethodBase.GetCurrentMethod().Name;
TakeScreenshot(imageName);
_page.Find(By.CssSelector("div[class*='ArtistIndex']")).Should().NotBeNull();
}
@ -30,6 +35,9 @@ namespace NzbDrone.Automation.Test
_page.CalendarNavIcon.Click();
_page.WaitForNoSpinner();
var imageName = MethodBase.GetCurrentMethod().Name;
TakeScreenshot(imageName);
_page.Find(By.CssSelector("div[class*='CalendarPage']")).Should().NotBeNull();
}
@ -39,6 +47,9 @@ namespace NzbDrone.Automation.Test
_page.ActivityNavIcon.Click();
_page.WaitForNoSpinner();
var imageName = MethodBase.GetCurrentMethod().Name;
TakeScreenshot(imageName);
_page.Find(By.LinkText("Queue")).Should().NotBeNull();
_page.Find(By.LinkText("History")).Should().NotBeNull();
_page.Find(By.LinkText("Blacklist")).Should().NotBeNull();
@ -60,6 +71,9 @@ namespace NzbDrone.Automation.Test
_page.SystemNavIcon.Click();
_page.WaitForNoSpinner();
var imageName = MethodBase.GetCurrentMethod().Name;
TakeScreenshot(imageName);
_page.Find(By.CssSelector("div[class*='Health']")).Should().NotBeNull();
}
@ -68,11 +82,12 @@ namespace NzbDrone.Automation.Test
{
_page.LibraryNavIcon.Click();
_page.WaitForNoSpinner();
_page.Find(By.LinkText("Add New")).Click();
_page.WaitForNoSpinner();
var imageName = MethodBase.GetCurrentMethod().Name;
TakeScreenshot(imageName);
_page.Find(By.CssSelector("input[class*='AddNewItem-searchInput']")).Should().NotBeNull();
}
}

Loading…
Cancel
Save