Skip to content

Commit 066c3dc

Browse files
authored
[Visualization] Avoid error "Cannot take screenshot with 0 width." (#127)
* [Visualization] Avoid error "Cannot take screenshot with 0 width." Stabilize FormDumpTests * Update azure-pipelines.yml for Azure Pipelines * fix coding issues
1 parent 476729b commit 066c3dc

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

Aquality.Selenium.Core/src/Aquality.Selenium.Core/Visualization/DumpManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public virtual void Save(string dumpName = null)
118118

119119
protected virtual List<KeyValuePair<string, T>> FilterElementsForVisualization()
120120
{
121-
return ElementsForVisualization.Where(element => element.Value.State.IsDisplayed).ToList();
121+
return ElementsForVisualization.Where(element => element.Value.State.IsDisplayed && element.Value.Visual.Size.Width > 0).ToList();
122122
}
123123

124124
protected virtual DirectoryInfo CleanUpAndGetDumpDirectory(string dumpName = null)

Aquality.Selenium.Core/src/Aquality.Selenium.Core/Visualization/ImageExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static SKImage Resize(this SKImage originalImage, int newWidth, int newHe
4040
using (var srcBitmap = SKBitmap.FromImage(originalImage))
4141
{
4242
var resizeInfo = new SKImageInfo(newWidth, newHeight);
43-
using (var smallVersion = srcBitmap.Resize(resizeInfo, SKFilterQuality.High))
43+
using (var smallVersion = srcBitmap.Resize(resizeInfo, new SKSamplingOptions(SKCubicResampler.Mitchell)))
4444
{
4545
return SKImage.FromBitmap(smallVersion);
4646
}

Aquality.Selenium.Core/src/Aquality.Selenium.Core/Visualization/VisualStateProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public SKImage Image
3333
private T GetLoggedValue<T>(string name, Func<WebElement, T> getValue, Func<T, string> toString = null)
3434
{
3535
logVisualState($"loc.el.visual.get{name.ToLower()}");
36-
var value = actionRetrier.DoWithRetry(() => getValue(getElement()));
36+
var value = actionRetrier.DoWithRetry(() => getValue(getElement()), new []{ typeof(WebDriverException) });
3737
logVisualState($"loc.el.visual.{name.ToLower()}.value", toString == null ? value.ToString() : toString(value));
3838
return value;
3939
}
@@ -49,7 +49,7 @@ public float GetDifference(SKImage theOtherOne, float? threshold = null)
4949
}
5050
else
5151
{
52-
logVisualState("loc.el.visual.getdifference.withthreshold", theOtherOne.Size().ToString(), threshold?.ToString("P", CultureInfo.InvariantCulture));
52+
logVisualState("loc.el.visual.getdifference.withthreshold", theOtherOne.Size().ToString(), threshold.Value.ToString("P", CultureInfo.InvariantCulture));
5353
}
5454

5555
if (currentImage != default)

Aquality.Selenium.Core/tests/Aquality.Selenium.Core.Tests/Visualization/FormDumpTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ public void Should_BePossibleTo_CompareWithDump_WithCustomName_WhenDifferenceIsZ
7171
public void Should_BePossibleTo_CompareWithDump_WithCustomName_WhenDifferenceIsNotZero()
7272
{
7373
var form = new WebForm();
74-
form.HoverAvatar();
7574
form.Dump.Save("Non-zero diff");
7675
AqualityServices.Application.Driver.Navigate().Refresh();
7776
form.WaitUntilPresent();
77+
form.HoverAvatar();
7878
Assert.That(form.Dump.Compare("Non-zero diff"), Is.GreaterThan(0), "Difference with current page should be greater than zero");
7979
}
8080

azure-pipelines.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,32 @@ stages:
1515
displayName: Analyse code with SonarQube
1616

1717
steps:
18-
- task: SonarCloudPrepare@1
18+
- task: SonarCloudPrepare@3
1919
displayName: 'Prepare SonarCloud analysis'
2020
inputs:
21-
SonarCloud: 'SonarCloud'
21+
SonarQube: 'SonarCloud'
2222
organization: 'aqualityautomation'
23+
scannerMode: 'dotnet'
2324
projectKey: 'aquality-automation_aquality-selenium-core-dotnet'
2425
projectName: 'aquality-selenium-core-dotnet'
2526
projectVersion: '$(Build.BuildNumber)'
26-
extraProperties: |
27-
sonar.coverage.exclusions=**/**
27+
extraProperties: 'sonar.coverage.exclusions=**/**'
2828

2929
- task: DotNetCoreCLI@2
3030
displayName: 'Build solution'
3131
inputs:
3232
command: 'build'
3333
projects: Aquality.Selenium.Core/Aquality.Selenium.Core.sln
3434
arguments: -c $(buildConfiguration)
35-
36-
- task: SonarCloudAnalyze@1
35+
- task: SonarCloudAnalyze@3
36+
inputs:
37+
jdkversion: 'JAVA_HOME_17_X64'
3738
displayName: 'Run SonarCloud code analysis'
3839
continueOnError: true
3940

40-
- task: SonarCloudPublish@1
41+
- task: SonarCloudPublish@3
42+
inputs:
43+
pollingTimeoutSec: '300'
4144
displayName: 'Publish SonarCloud quality gate results'
4245

4346
- job: tests
@@ -114,15 +117,18 @@ stages:
114117
- script: dotnet pack Aquality.Selenium.Core\src\Aquality.Selenium.Core\Aquality.Selenium.Core.csproj -c $(buildConfiguration) -p:Version=$(GitVersion.NuGetVersion) -o $(Build.ArtifactStagingDirectory)
115118
displayName: 'Create NuGet package'
116119

117-
- task: GitHubRelease@0
120+
- task: GitHubRelease@1
118121
displayName: 'Create tag on GitHub'
119122
inputs:
120123
gitHubConnection: 'github.com_aqualityautomation'
121124
repositoryName: 'aquality-automation/aquality-selenium-core-dotnet'
122125
action: 'create'
126+
target: '$(Build.SourceVersion)'
127+
tagSource: 'userSpecifiedTag'
123128
tag: 'v$(GitVersion.NuGetVersion)'
124-
tagSource: 'manual'
125-
isPreRelease: contains(variables['GitVersion.NuGetVersion'], '-')
129+
isDraft: contains(variables['GitVersion.NuGetVersion'], '-')
130+
changeLogCompareToRelease: 'lastFullRelease'
131+
changeLogType: 'commitBased'
126132

127133
- task: NuGetCommand@2
128134
displayName: 'Push NuGet package'

0 commit comments

Comments
 (0)