Skip to content

Commit

Permalink
Feature/46 update form interface [+semver: feature] (#49)
Browse files Browse the repository at this point in the history
* Remove IsDiaplayed property from Form, update core version

* Update pipeline

* Fix pipeline

* Fix tests

* Fix test

* Update pipeline

* Fix test

* Update test

* Try to fix test

* Try to fix test
  • Loading branch information
paveliam authored May 11, 2020
1 parent facd820 commit 480a0fa
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<IsPackable>true</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>Aquality.WinAppDriver.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
Expand Down Expand Up @@ -46,7 +46,7 @@

<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="4.1.1" />
<PackageReference Include="Aquality.Selenium.Core" Version="0.3.9" />
<PackageReference Include="Aquality.Selenium.Core" Version="1.0.0" />
</ItemGroup>

</Project>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions Aquality.WinAppDriver/src/Aquality.WinAppDriver/Forms/Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ private static Func<ISearchContext> ResolveSearchContextSupplier(IForm parentFor
? null
: (Func<ISearchContext>)(() => parentForm.GetElement());
}

/// <summary>
/// Return window state for form locator
/// </summary>
/// <value>True - form is opened,
/// False - form is not opened.</value>
public virtual bool IsDisplayed => State.WaitForDisplayed();

/// <summary>
/// Element factory <see cref="IElementFactory"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ namespace Aquality.WinAppDriver.Forms
/// </summary>
public interface IForm : IElement
{
/// <summary>
/// Return window state for form locator
/// </summary>
/// <value>True - form is opened,
/// False - form is not opened.</value>
bool IsDisplayed { get; }

/// <summary>
/// Gets size of the form element defined by its locator.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void Should_BePossibleTo_SetWindowHandleApplicationFactory()
{
ProcessManager.Start(ApplicationPath);
AqualityServices.SetWindowHandleApplicationFactory(rootSession => new CalculatorWindow(() => rootSession).GetNativeWindowHandle());
Assert.IsTrue(new CalculatorForm().IsDisplayed);
Assert.IsTrue(new CalculatorForm().State.IsDisplayed);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ public void Should_ThrowException_InGetSize_WhenFormIsNotPresent()
[Test]
public void Should_ReturnTrue_IfFormIsDisplayed()
{
Assert.IsTrue(CalculatorForm.IsDisplayed);
CalculatorForm.State.WaitForDisplayed();
Assert.IsTrue(CalculatorForm.State.IsDisplayed);
}

[Test]
public void Should_ReturnFalse_IfFormIsNotDisplayed()
{
Assert.IsFalse(TestForm.IsDisplayed);
Assert.IsFalse(TestForm.State.IsDisplayed);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Aquality.WinAppDriver.Tests.Forms.Chrome
{
public class ChromeNavigationPanel : Form
{
public ChromeNavigationPanel() : base(By.XPath("//Pane[./Button[@Name='Chrome']]"), $"Chrome Navigation panel")
public ChromeNavigationPanel() : base(By.XPath("//Pane[./*[@Name='Chrome']]"), $"Chrome Navigation panel")
{
}

Expand All @@ -15,7 +15,7 @@ public void OpenDownloads()
KeyboardActions.SendKeysWithKeyHold("j", ModifierKey.Control);
}

public void OpenNewTab()
public void OpenNewWindow()
{
KeyboardActions.SendKeysWithKeyHold("n", ModifierKey.Control);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@ public void Close()
{
KeyboardActions.SendKeysWithKeyHold("w", ModifierKey.Control, mayDisappear: true);
}

public override bool IsDisplayed => State.IsDisplayed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@ public void Should_BePossibleTo_WorkWithTwoWindows()

AqualityServices.SetWindowHandleApplicationFactory(rootSession => new CoreChromeWindow(rootSession).NativeWindowHandle);
var navigationPanel = new ChromeNavigationPanel();
Assert.IsTrue(navigationPanel.IsDisplayed);
var firstTabName = AqualityServices.Application.Driver.Title;
var firstWindow = new ChromeWindow(firstTabName);
Assert.IsTrue(firstWindow.IsDisplayed, $"{firstWindow.Name} window is not displayed");
Assert.IsTrue(navigationPanel.State.WaitForDisplayed());
var firstWindowName = AqualityServices.Application.Driver.Title;
var firstWindow = new ChromeWindow(firstWindowName);
Assert.IsTrue(firstWindow.State.WaitForDisplayed(), $"{firstWindow.Name} window is not displayed");

firstWindow.Click();
navigationPanel.OpenDownloads();
firstWindow = new ChromeWindow(DownloadsTabName);
Assert.IsTrue(firstWindow.IsDisplayed, $"First window is not displayed with the new name {firstWindow.Name}");
navigationPanel.OpenNewTab();
Assert.IsTrue(firstWindow.State.WaitForDisplayed(), $"First window is not displayed with the new name {firstWindow.Name}");

navigationPanel.OpenNewWindow();
var secondWindow = new ChromeWindow(NewTabName);
Assert.IsTrue(secondWindow.IsDisplayed, $"Second window with the name {secondWindow.Name} is not displayed");
Assert.IsTrue(secondWindow.State.WaitForDisplayed(), $"Second window with the name {secondWindow.Name} is not displayed");

secondWindow.Click();
secondWindow.Close();
Assert.IsFalse(secondWindow.IsDisplayed, "Second window is not closed");
Assert.IsTrue(firstWindow.IsDisplayed, "First window is closed but should not");
secondWindow.State.WaitForNotDisplayed();
Assert.IsFalse(secondWindow.State.IsDisplayed, "Second window is not closed");
Assert.IsTrue(firstWindow.State.IsDisplayed, "First window is closed but should not");
}

[TearDown]
Expand Down
177 changes: 99 additions & 78 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,108 @@
variables:
buildConfiguration: 'Release'
isRemote: true

trigger:
- master

pool:
vmImage: 'windows-latest'

steps:
- task: GitVersion@5
displayName: 'Run GitVersion'
inputs:
runtime: 'core'

- task: SonarCloudPrepare@1
displayName: 'Prepare SonarCloud analysis'
inputs:
SonarCloud: 'SonarCloud'
organization: 'aqualityautomation'
projectKey: 'aquality-automation_aquality-winappdriver-dotnet'
projectName: 'aquality-winappdriver-dotnet'
projectVersion: '$(Build.BuildNumber)'
extraProperties: |
sonar.coverage.exclusions=**/**
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: Aquality.WinAppDriver/Aquality.WinAppDriver.sln
arguments: -c $(buildConfiguration)

- task: SonarCloudAnalyze@1
displayName: 'Run SonarCloud code analysis'
continueOnError: true

- task: SonarCloudPublish@1
displayName: 'Publish SonarCloud quality gate results'
continueOnError: true

- task: ScreenResolutionUtility@1
displayName: 'Set up screen resolution 1920x1080'
inputs:
displaySettings: 'specific'
width: '1920'
height: '1080'

- task: Windows Application Driver@0
displayName: 'Start WinAppDriver'
inputs:
OperationType: 'Start'

- task: DotNetCoreCLI@2
displayName: 'Run tests'
inputs:
command: 'test'
projects: '**/*Tests*/*.csproj'
arguments: -c $(buildConfiguration) --no-build
publishTestResults: true

- task: Windows Application Driver@0
displayName: Stop WinAppDriver
inputs:
OperationType: 'Stop'

- script: dotnet pack Aquality.WinAppDriver\src\Aquality.WinAppDriver\Aquality.WinAppDriver.csproj -c $(buildConfiguration) --no-build -p:Version=$(GitVersion.NuGetVersion) -o $(Build.ArtifactStagingDirectory)
displayName: 'Pack to NuGet package'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
variables:
buildConfiguration: 'Release'

stages:
- stage: test

jobs:
- job: sonar
displayName: Analyse code with SonarQube

steps:
- task: SonarCloudPrepare@1
displayName: 'Prepare SonarCloud analysis'
inputs:
SonarCloud: 'SonarCloud'
organization: 'aqualityautomation'
projectKey: 'aquality-automation_aquality-winappdriver-dotnet'
projectName: 'aquality-winappdriver-dotnet'
projectVersion: '$(Build.BuildNumber)'
extraProperties: |
sonar.coverage.exclusions=**/**
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: Aquality.WinAppDriver/Aquality.WinAppDriver.sln
arguments: -c $(buildConfiguration)

- task: SonarCloudAnalyze@1
displayName: 'Run SonarCloud code analysis'
continueOnError: true

- task: GitHubRelease@0
displayName: 'Create tag on GitHub'
inputs:
gitHubConnection: 'GitHub'
repositoryName: 'aquality-automation/aquality-winappdriver-dotnet'
action: 'create'
tag: 'v$(GitVersion.NuGetVersion)'
tagSource: 'manual'
isPreRelease: contains(variables['GitVersion.NuGetVersion'], '-')
- task: SonarCloudPublish@1
displayName: 'Publish SonarCloud quality gate results'

- job: tests
displayName: Run tests

variables:
isRemote: true

steps:
- task: ScreenResolutionUtility@1
displayName: 'Set up screen resolution 1920x1080'
inputs:
displaySettings: 'specific'
width: '1920'
height: '1080'

- task: Windows Application Driver@0
displayName: 'Start WinAppDriver'
inputs:
OperationType: 'Start'

- task: DotNetCoreCLI@2
displayName: 'Run tests'
inputs:
command: 'test'
projects: '**/*Tests*/*.csproj'
arguments: -c $(buildConfiguration)
publishTestResults: true

- task: Windows Application Driver@0
displayName: Stop WinAppDriver
inputs:
OperationType: 'Stop'

- stage: deploy
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))

- task: PublishBuildArtifacts@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: '_aquality-automation.aquality-winappdriver-dotnet'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- job: release
displayName: 'Create tag on GitHub and publish NuGet package'

steps:
- task: GitVersion@5
displayName: 'Run GitVersion'
inputs:
runtime: 'core'

- script: dotnet pack Aquality.WinAppDriver\src\Aquality.WinAppDriver\Aquality.WinAppDriver.csproj -c $(buildConfiguration) -p:Version=$(GitVersion.NuGetVersion) -o $(Build.ArtifactStagingDirectory)
displayName: 'Pack to NuGet package'

- task: GitHubRelease@0
displayName: 'Create tag on GitHub'
inputs:
gitHubConnection: 'GitHub'
repositoryName: 'aquality-automation/aquality-winappdriver-dotnet'
action: 'create'
tag: 'v$(GitVersion.NuGetVersion)'
title: 'v$(GitVersion.NuGetVersion)'
tagSource: 'manual'
isPreRelease: contains(variables['GitVersion.NuGetVersion'], '-')

- task: NuGetCommand@2
displayName: 'Push NuGet package'
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/Aquality.WinAppDriver*.nupkg;!$(Build.ArtifactStagingDirectory)/**/Aquality.WinAppDriver*.symbols.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'NuGet'

0 comments on commit 480a0fa

Please sign in to comment.