Skip to content

Commit

Permalink
Fixes for checking GetField().IsRequired on BPF (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
TYLEROL authored Sep 21, 2020
1 parent f6cbaac commit 10a8686
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Microsoft.Dynamics365.UIAutomation.Api.UCI/Controls/Field.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ public bool IsRequired
{
get
{
if (containerElement.HasElement(By.XPath(AppElements.Xpath[AppReference.Field.Required])))
if (containerElement.HasElement(By.XPath(AppElements.Xpath[AppReference.Field.RequiredIcon])))
{
var required = containerElement.FindElement(By.XPath(AppElements.Xpath[AppReference.Field.Required]));
var required = containerElement.FindElement(By.XPath(AppElements.Xpath[AppReference.Field.RequiredIcon]));

if (required.GetAttribute("aria-required") == "true")
if (required != null)
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ public static class BusinessProcessFlow
public static string BusinessProcessFlowFieldName = "BPF_FieldName_UCI";
public static string BusinessProcessFlowFormContext = "BPF_FormContext";
public static string TextFieldContainer = "BPF_TextFieldContainer";
public static string FieldSectionItemContainer = "BPF_FieldSectionItemContainer";
public static string TextFieldLabel = "BPF_TextFieldLabel";
public static string BooleanFieldContainer = "BPF_BooleanFieldContainer";
public static string DateTimeFieldContainer = "BPF_DateTimeFieldContainer";
Expand Down Expand Up @@ -308,6 +309,7 @@ public static class Field
{
public static string ReadOnly = "Field_ReadOnly";
public static string Required = "Field_Required";
public static string RequiredIcon = "Field_RequiredIcon";
}
public static class PerformanceWidget
{
Expand Down Expand Up @@ -526,6 +528,7 @@ public static class AppElements
{ "BPF_NextStageButton_UCI" , "//button[contains(@data-id,'nextButtonContainer')]" },
{ "BPF_SetActiveButton", "//button[contains(@data-id,'setActiveButton')]" },
{ "BPF_FieldName_UCI" , "//input[contains(@id,'[NAME]')]" },
{ "BPF_FieldSectionItemContainer", ".//div[contains(@id, \'header_process_[NAME]-FieldSectionItemContainer\')]" },
{ "BPF_FormContext" , "//div[contains(@id, \'ProcessStageControl-processHeaderStageFlyoutInnerContainer\')]" },
{ "BPF_TextFieldContainer", ".//div[contains(@data-lp-id, \'header_process_[NAME]\')]" },
{ "BPF_TextFieldLabel", "//label[contains(@id, \'header_process_[NAME]-field-label\')]" },
Expand All @@ -545,6 +548,7 @@ public static class AppElements
//Field
{"Field_ReadOnly",".//*[@aria-readonly]" },
{"Field_Required", ".//*[@aria-required]"},
{"Field_RequiredIcon", ".//div[contains(@data-id, 'required-icon') or contains(@id, 'required-icon')]"},

//Dialogs
{ "AssignDialog_ToggleField" , "//label[contains(@data-id,'rdoMe_id.fieldControl-checkbox-inner-first')]" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -31,6 +32,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.ApplicationInsights, Version=2.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -113,6 +115,10 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Dynamics365.UIAutomation.Api\Microsoft.Dynamics365.UIAutomation.Api.csproj">
<Project>{dfe2c141-f1aa-4d4b-8df8-0fb93023cf45}</Project>
<Name>Microsoft.Dynamics365.UIAutomation.Api</Name>
</ProjectReference>
<ProjectReference Include="..\Microsoft.Dynamics365.UIAutomation.Browser\Microsoft.Dynamics365.UIAutomation.Browser.csproj">
<Project>{c9748803-f3cb-4531-b313-bc24d4d0bf0c}</Project>
<Name>Microsoft.Dynamics365.UIAutomation.Browser</Name>
Expand Down
5 changes: 4 additions & 1 deletion Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4742,7 +4742,10 @@ internal BrowserCommandResult<Field> BPFGetField(string field)
{
return this.Execute(GetOptions($"Get Field"), driver =>
{
var fieldElement = driver.WaitUntilAvailable(By.XPath(AppElements.Xpath[AppReference.BusinessProcessFlow.TextFieldContainer].Replace("[NAME]", field)));

// Initialize the Business Process Flow context
var formContext = driver.WaitUntilAvailable(By.XPath(AppElements.Xpath[AppReference.BusinessProcessFlow.BusinessProcessFlowFormContext]));
var fieldElement = formContext.WaitUntilAvailable(By.XPath(AppElements.Xpath[AppReference.BusinessProcessFlow.FieldSectionItemContainer].Replace("[NAME]", field)));
Field returnField = new Field(fieldElement);
returnField.Name = field;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -31,6 +32,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -31,6 +32,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -36,6 +37,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.ApplicationInsights, Version=2.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down

0 comments on commit 10a8686

Please sign in to comment.