Skip to content

Commit

Permalink
PSP-9565: Automation test set update IS94 and Changes on Github action (
Browse files Browse the repository at this point in the history
#4509)

* data changes

* Testing browsers

* changing .net 6.0 to .net 8.0

* Deleting EdgeDriver nuget package

* Changes on webdriver config

* Update integration-test.yml

* Changes on automation test set - IS94
  • Loading branch information
stairaku authored Nov 30, 2024
1 parent c37b61a commit 689e0ca
Show file tree
Hide file tree
Showing 23 changed files with 79 additions and 95 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x

#- name: Installing Edge Browser (alternative step)
# run: |
# wget -O - https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/microsoft.gpg
# sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge.list'
# sudo apt update
# sudo apt install -y microsoft-edge-stable
dotnet-version: 8.0.x

- name: Install Chrome Browser
run: |
sudo apt update
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install -y ./google-chrome-stable_current_amd64.deb
# Edge Browser setup - missing dependencies
#- uses: browser-actions/setup-edge@v1
#- name: Print Edge version
# run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion

- name: Restore dependencies
run: dotnet restore ./testing/PIMS.Tests.Automation/PIMS.Tests.Automation.sln
- name: Build
Expand Down
Binary file modified testing/PIMS.Tests.Automation/Data/PIMS_Testing_Data.xlsx
Binary file not shown.
32 changes: 9 additions & 23 deletions testing/PIMS.Tests.Automation/Drivers/BrowserDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.Extensions.Configuration;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Firefox;

namespace PIMS.Tests.Automation.Drivers
Expand All @@ -17,7 +16,7 @@ public class BrowserDriver : IDisposable

public BrowserDriver()
{
currentWebDriverLazy = new Lazy<IWebDriver>(CreateFirefoxWebDriver);
currentWebDriverLazy = new Lazy<IWebDriver>(CreateChromeWebDriver);
configurationLazy = new Lazy<IConfiguration>(ReadConfiguration);
closeBrowserOnDispose = Configuration.GetValue("CloseBrowserAfterEachTest", true);
runAutomationHeadless = Configuration.GetValue("RunHeadless", true);
Expand All @@ -30,39 +29,26 @@ public BrowserDriver()
private IWebDriver CreateChromeWebDriver()
{
ChromeOptions options = new ChromeOptions();
options.AddArgument("start-maximized");
options.AddExcludedArgument("enable-automation");
options.AddArgument("--incognito");
options.AddArgument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Firefox/91.0 Safari/537.36");

if (runAutomationHeadless)
options.AddArguments("window-size=1920,1080", "headless", "no-sandbox");
else
options.AddArguments("start-maximized", "no-sandbox");

options.AddArgument("--headless=new");

var chromeDriver = new ChromeDriver(ChromeDriverService.CreateDefaultService(), options, TimeSpan.FromMinutes(3));
chromeDriver.Url = Configuration.GetValue<string>("Base_url");

return chromeDriver;
}

private IWebDriver CreateEdgeWebDriver()
{
var options = new EdgeOptions();
if (runAutomationHeadless)
options.AddArguments("window-size=1920,1080", "headless", "no-sandbox");
else
options.AddArguments("start-maximized", "no-sandbox");

var edgeDriver = new EdgeDriver(EdgeDriverService.CreateDefaultService(), options, TimeSpan.FromMinutes(3));
edgeDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(120);
edgeDriver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(120);
edgeDriver.Url = Configuration.GetValue<string>("Base_url");

return edgeDriver;
}

private IWebDriver CreateFirefoxWebDriver()
{
var options = new FirefoxOptions();
if (runAutomationHeadless)
options.AddArguments("--headless");


var firefoxDriver = new FirefoxDriver(FirefoxDriverService.CreateDefaultService(), options);
firefoxDriver.Manage().Window.Maximize();
Expand All @@ -82,9 +68,9 @@ public void Dispose()
{
if (currentWebDriverLazy.IsValueCreated && closeBrowserOnDispose)
{
Current.Close();
Current.Quit();
Current.Dispose();
Current.Close();
}
}
}
Expand Down
21 changes: 10 additions & 11 deletions testing/PIMS.Tests.Automation/PIMS.Tests.Automation.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>484766ab-9711-4242-858c-ae7c826b3074</UserSecretsId>
Expand All @@ -18,19 +18,18 @@
<PackageReference Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
<PackageReference Include="ExcelDataReader" Version="3.7.0" />
<PackageReference Include="ExcelDataReader.DataSet" Version="3.7.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Selenium.Support" Version="4.25.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="130.0.6723.6900" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Selenium.Support" Version="4.26.1" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="131.0.6778.8500" />
<PackageReference Include="Selenium.WebDriver.GeckoDriver" Version="0.35.0" />
<PackageReference Include="Selenium.WebDriver.MSEdgeDriver" Version="129.0.2792.89" />
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" />
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="FluentAssertions" Version="6.12.2" />
<PackageReference Include="SpecFlow.xUnit" Version="3.9.74" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.0" />
<PackageReference Include="System.Text.Json" Version="9.0.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class AcquisitionDetails : PageObjectBase
private readonly By menuAcquisitionButton = By.CssSelector("div[data-testid='nav-tooltip-acquisition'] a");
private readonly By createAcquisitionFileButton = By.XPath("//a[contains(text(),'Create an Acquisition File')]");

private readonly By acquisitionFileSummaryBttn = By.CssSelector("div[data-testid='menu-item-row-0'] div span[title='File Details']");
private readonly By acquisitionFileSummaryBttn = By.CssSelector("div[data-testid='menu-item-row-0'] div button[title='File Details']");
private readonly By acquisitionFileDetailsTab = By.XPath("//a[contains(text(),'File details')]");

//Acquisition File Details View Form Elements
Expand Down Expand Up @@ -316,7 +316,6 @@ public void SaveAcquisitionFileDetails()
sharedModals.ModalClickOKBttn();

Wait();
WaitUntilVisible(acquisitionFileDetailsTab);
}
else if (sharedModals.ModalContent().Contains("The selected property already exists in the system's inventory."))
{
Expand All @@ -325,8 +324,7 @@ public void SaveAcquisitionFileDetails()
Assert.Contains("To add the property, the spatial details for this property will need to be updated. The system will attempt to update the property record with spatial information from the current selection.", sharedModals.ModalContent());
sharedModals.ModalClickOKBttn();

Wait();
WaitUntilVisible(acquisitionFileDetailsTab);
Wait();
}
else if (sharedModals.ModalContent().Contains("This change will be reflected on other related entities - generated documents, sub-files, etc."))
{
Expand All @@ -336,7 +334,6 @@ public void SaveAcquisitionFileDetails()
sharedModals.ModalClickOKBttn();

Wait();
WaitUntilVisible(acquisitionFileDetailsTab);
}
else if (sharedModals.ModalHeader().Contains("Error"))
{
Expand Down Expand Up @@ -754,12 +751,14 @@ private void VerifyRequiredTeamMemberMessages()

//Verify that invalid team member message is displayed
ChooseSpecificSelectOption(By.Id("input-team.0.contactTypeCode"), "Expropriation agent");
webDriver.FindElement(acquisitionFileTeamSubtitle).Click();
AssertTrueIsDisplayed(acquisitionFileTeamInvalidTeamMemberMessage);

//verify that invalid profile message is displayed
webDriver.FindElement(By.CssSelector("div[data-testid='contact-input'] button[title='Select Contact']")).Click();
sharedSelectContact.SelectContact("Test", "");
ChooseSpecificSelectOption(By.Id("input-team.0.contactTypeCode"), "Select profile...");
webDriver.FindElement(acquisitionFileTeamSubtitle).Click();
AssertTrueIsDisplayed(acquisitionFileTeamInvalidProfileMessage);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,6 @@ public void CancelExpropriation()
Wait();
ButtonElement("Cancel");

//if (webDriver.FindElements(acquisitionFileConfirmationModal).Count() > 0)
//{
// Assert.Equal("Confirm Changes", sharedModals.ModalHeader());
// Assert.Contains("If you choose to cancel now, your changes will not be saved.", sharedModals.ModalContent());
// Assert.Contains("Do you want to proceed?", sharedModals.ModalContent());

// sharedModals.ModalClickOKBttn();
//}
sharedModals.CancelActionModal();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public void VerifyInterestStakeholderViewForm(AcquisitionStakeholder interest)
AssertTrueIsDisplayed(stakeholderInterestsEditBttn);
AssertTrueIsDisplayed(stakeholderInterestTable);

Wait();
var lastStakeholder = webDriver.FindElements(stakeholderInterestTotalCount).Count();
AssertTrueContentEquals(By.XPath("//div[contains(text(),'Interests')]/parent::div/parent::div/parent::div/parent::h2/following-sibling::div/div[@data-testid='interest-holders-by-property-table']/div[@class='tbody']/div[@class='tr-wrapper']["+ lastStakeholder +"]/div/div[1]/a"), interest.InterestHolder);
AssertTrueContentEquals(By.XPath("//div[contains(text(),'Interests')]/parent::div/parent::div/parent::div/parent::h2/following-sibling::div/div[@data-testid='interest-holders-by-property-table']/div[@class='tbody']/div[@class='tr-wrapper']["+ lastStakeholder +"]/div/div[2]"), interest.PrimaryContact);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public AcquisitionTakes(IWebDriver webDriver) : base(webDriver)

public void NavigateTakesTab()
{
WaitUntilClickable(takesTabLink);
Wait();
webDriver.FindElement(takesTabLink).Click();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public class DigitalDocuments: PageObjectBase
private readonly By documentOtherTypePINInput = By.CssSelector("input[data-testid='metadata-input-PIN']");
private readonly By documentOtherTypePropIdLabel = By.XPath("//input[@data-testid='metadata-input-PROPERTY_IDENTIFIER']/parent::div/parent::div/preceding-sibling::div/label[contains(text(),'Property identifier')]");
private readonly By documentRoadNameInput = By.CssSelector("input[data-testid='metadata-input-ROAD_NAME']");
private readonly By documentShortDescriptorLabel = By.XPath("//label[contains(text(),'Short descriptor')]");
private readonly By documentShortDescriptorLabel = By.XPath("//input[@data-testid='metadata-input-SHORT_DESCRIPTOR']/parent::div/parent::div/preceding-sibling::div/label[contains(text(),'Short descriptor')]");

//Upload PA plans Fields
private readonly By documentPAPlanNbrLabel = By.XPath("//label[contains(text(),'Plan #')]");
Expand Down
4 changes: 2 additions & 2 deletions testing/PIMS.Tests.Automation/PageObjects/LeaseDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public class LeaseDetails : PageObjectBase
private readonly By licenseHeaderNbrContent = By.XPath("/html[1]/body[1]/div[1]/div[2]/div[2]/div[1]/div[1]/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/span[1]");
private readonly By licenseHeaderAccountType = By.XPath("//label[contains(text(),'Lease/Licence #')]/parent::div/following-sibling::div/span[2]");
private readonly By licenseHeaderProperty = By.XPath("//h1[contains(text(),'Lease / Licence')]/parent::div/parent::div/following-sibling::div[2]/div[1]/div/div/div/div[2]/div/label[contains(text(),'Property')]");
private readonly By licenseHeaderPropertyContent = By.XPath("//h1[contains(text(),'Lease / Licence')]/parent::div/parent::div/following-sibling::div[2]/div[1]/div/div/div/div[2]/div/label[contains(text(),'Property')]/parent::div/following-sibling::div/div/span");
private readonly By licenseHeaderPropertyContent = By.XPath("//h1[contains(text(),'Lease / Licence')]/parent::div/parent::div/following-sibling::div[2]/div[1]/div/div/div/div[2]/div/label[contains(text(),'Property')]/parent::div/following-sibling::div/span");
private readonly By licenseHeaderTenantLabel = By.XPath("//label[contains(text(),'Tenant')]");
private readonly By licenseHeaderPayeeLabel = By.XPath("//label[contains(text(),'Payee')]");
private readonly By licenseHeaderStartDateLabel = By.XPath("//h1/parent::div/parent::div/following-sibling::div[2]/div/div/div/div/div[4]/div/label[contains(text(),'Commencement')]");
private readonly By licenseHeaderStartDateContent = By.XPath("//label[contains(text(),'Commencement')]/parent::div/following-sibling::div[1]");
private readonly By licenseHeaderExpiryDateLabel = By.XPath("//label[contains(text(),'Commencement')]/parent::div/following-sibling::div[2]/label[contains(text(),'Expiry')]");
private readonly By licenseHeaderExpiryDateContent = By.XPath("//label[contains(text(),'Commencement')]/parent::div/following-sibling::div[2]/label[contains(text(),'Expiry')]/parent::div/following-sibling::div[1]");
private readonly By licenseHeaderHistoricalFileLabel = By.XPath("//label[contains(text(),'Historical file')]");
private readonly By licenseHeaderHistoricalFileContent = By.XPath("//label[contains(text(),'Historical file #:')]/parent::div/following-sibling::div/div/span");
private readonly By licenseHeaderHistoricalFileContent = By.XPath("//label[contains(text(),'Historical file #:')]/parent::div/following-sibling::div/span");

private readonly By licenseHeaderCreatedLabel = By.XPath("//span/strong[contains(text(),'Created')]");
private readonly By licenseHeaderCreatedContent = By.XPath("//strong[contains(text(),'Created')]/parent::span");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void NavigateToImprovementSection()
//Edit Improvements section
public void EditImprovements()
{
WaitUntilClickable(improvementEditIcon);
Wait();
webDriver.FindElement(improvementEditIcon).Click();

WaitUntilSpinnerDisappear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ public void UpdatePropertyDetails(Property property)
{
foreach (string status in property.TenureStatus)
{
Wait(2000);
webDriver.FindElement(propertyDetailsTenureStatusLabel).Click();
FocusAndClick(propertyDetailsTenureStatusInput);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ public void InsertManagementSummaryInformation(PropertyManagement managementProp
ClearMultiSelectInput(managementPropertyPurposeInput);
foreach (string purpose in managementProperty.ManagementPropertyPurpose)
{
Wait();
webDriver.FindElement(managementPropertyPurposeLabel).Click();
FocusAndClick(managementPropertyPurposeInput);

WaitUntilClickable(managementPropertyPurposeOptions);
ChooseMultiSelectSpecificOption(managementPropertyPurposeOptions, purpose);
webDriver.FindElement(managementPropertyPurposeLabel).Click();
}
Expand Down
7 changes: 4 additions & 3 deletions testing/PIMS.Tests.Automation/PageObjects/ResearchFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class ResearchFiles : PageObjectBase
private readonly By researchFileHelpNameTooltip = By.XPath("//div[contains(text(),'Help with choosing a name')]");

//Research File Tabs and File Summary Elements
private readonly By researchFileSummaryBttn = By.CssSelector("div[data-testid='menu-item-row-0'] button[title='File Details']");
private readonly By researchFileSummaryBttn = By.CssSelector("div[data-testid='menu-item-row-0'] div button[title='File Details']");
private readonly By researchFileSummaryBttnPlaceholder = By.CssSelector("div[data-testid='menu-item-row-0'] div span[title='File Details']");
private readonly By researchFileDetailsTab = By.CssSelector("a[data-rb-event-key='fileDetails']");
private readonly By researchFileDocumentsTab = By.CssSelector("a[data-rb-event-key='documents']");
private readonly By researchFileNotesTab = By.CssSelector("a[data-rb-event-key='notes']");
Expand Down Expand Up @@ -571,14 +572,14 @@ public void VerifyResearchFileCreateInitForm()
//Verify Edit Research File Init Form
public void VerifyResearchFileEditInitForm(ResearchFile researchFile, string user)
{
WaitUntilVisible(researchFileSummaryBttn);
WaitUntilVisible(researchFileSummaryBttnPlaceholder);

//Header
VerifyResearchFileHeader(researchFile, user);
AssertTrueContentEquals(researchFileHeaderStatusContent,GetUppercaseString(researchFile.Status));

//Left Bar Elements
AssertTrueIsDisplayed(researchFileSummaryBttn);
AssertTrueIsDisplayed(researchFileSummaryBttnPlaceholder);
AssertTrueIsDisplayed(researchFilePropertiesLeftSection);
AssertTrueIsDisplayed(researchEditPropertiesBttn);

Expand Down
Loading

0 comments on commit 689e0ca

Please sign in to comment.