Index: System tests/AutomatedSystemTests/AutomatedSystemTests/Modules/Calculation/GetValueParameterInPropertiesPanelGivenPath.cs =================================================================== diff -u -r35e1f5d8cc279c74a0d63d6cfb8916fe5d132ef4 -r811b4eb3c65fc8c315cb7e8a9fbb49a5c3d0b2c5 --- System tests/AutomatedSystemTests/AutomatedSystemTests/Modules/Calculation/GetValueParameterInPropertiesPanelGivenPath.cs (.../GetValueParameterInPropertiesPanelGivenPath.cs) (revision 35e1f5d8cc279c74a0d63d6cfb8916fe5d132ef4) +++ System tests/AutomatedSystemTests/AutomatedSystemTests/Modules/Calculation/GetValueParameterInPropertiesPanelGivenPath.cs (.../GetValueParameterInPropertiesPanelGivenPath.cs) (revision 811b4eb3c65fc8c315cb7e8a9fbb49a5c3d0b2c5) @@ -18,6 +18,7 @@ using Ranorex; using Ranorex.Core; using Ranorex.Core.Testing; +using Ranorex_Automation_Helpers.UserCodeCollections; namespace AutomatedSystemTests.Modules.Calculation { @@ -62,54 +63,11 @@ /// that will in turn invoke this method. void ITestModule.Run() { - Mouse.DefaultMoveTime = 0; - Keyboard.DefaultKeyPressTime = 0; - Delay.SpeedFactor = 0.0; - AutomatedSystemTestsRepository myRepository = global::AutomatedSystemTests.AutomatedSystemTestsRepository.Instance; Adapter propertiesPanelAdapter = myRepository.RiskeerMainWindow.ContainerMultipleViews.PropertiesPanelContainer.Table.Self; - Ranorex.Row row = GetRowInPropertiesPanelGivenPath(propertiesPanelAdapter, pathToElementInPropertiesPanel); - + + Ranorex.Row row = PropertiesPanelHelpers.GetRowInPropertiesPanelGivenPath(pathToElementInPropertiesPanel, propertiesPanelAdapter); valueOfElement = row.Element.GetAttributeValueText("AccessibleValue"); } - - public Ranorex.Row GetRowInPropertiesPanelGivenPath(Adapter argumentAdapter, string pathItem) - { - int minimumIndex = 0; - var stepsPathItem = pathItem.Split('>').ToList(); - Ranorex.Row stepRow = argumentAdapter.As().Rows.ToList()[1]; - for (int i=0; i < stepsPathItem.Count; i++) { - // Find the item corresponding to the step - var step = stepsPathItem[i]; - var completeList = argumentAdapter.As
().Rows.ToList(); - var searchList = completeList.GetRange(minimumIndex, completeList.Count-minimumIndex); - var indexStepRow = searchList.FindIndex(rw => rw.GetAttributeValue("AccessibleName").Contains(step)); - stepRow = searchList[indexStepRow]; - - // if step is intermediate - if (i != stepsPathItem.Count - 1) - { - var stateStepRow = stepRow.Element.GetAttributeValueText("AccessibleState"); - // if intermediate step is collapsed - if (stateStepRow.Contains("Collapsed")) { - // Select and expand the intermediate item - Report.Log(ReportLevel.Info, "was collapsed"); - stepRow.Focus(); - stepRow.Select(); - stepRow.PressKeys("{Right}"); - } - } - else - { - // Select the final item - stepRow.Focus(); - stepRow.Select(); - } - // Update the minimum index administration (only search forward) - minimumIndex += 1 + indexStepRow; - } - return stepRow; - } - } } Index: System tests/AutomatedSystemTests/AutomatedSystemTests/Modules/Set_Assign/SetValueParameterInPropertiesPanelGivenPathTypeAndNewValue.cs =================================================================== diff -u -red71a901ea631ee06207ccb7ae043e9c67c15621 -r811b4eb3c65fc8c315cb7e8a9fbb49a5c3d0b2c5 --- System tests/AutomatedSystemTests/AutomatedSystemTests/Modules/Set_Assign/SetValueParameterInPropertiesPanelGivenPathTypeAndNewValue.cs (.../SetValueParameterInPropertiesPanelGivenPathTypeAndNewValue.cs) (revision ed71a901ea631ee06207ccb7ae043e9c67c15621) +++ System tests/AutomatedSystemTests/AutomatedSystemTests/Modules/Set_Assign/SetValueParameterInPropertiesPanelGivenPathTypeAndNewValue.cs (.../SetValueParameterInPropertiesPanelGivenPathTypeAndNewValue.cs) (revision 811b4eb3c65fc8c315cb7e8a9fbb49a5c3d0b2c5) @@ -19,6 +19,7 @@ using Ranorex.Core; using Ranorex.Core.Repository; using Ranorex.Core.Testing; +using Ranorex_Automation_Helpers.UserCodeCollections; namespace AutomatedSystemTests.Modules.Set_Assign { @@ -55,73 +56,8 @@ set { _newValueForParameter = value; } } - public Ranorex.Row GetRowInPropertiesPanelGivenPath(Adapter argumentAdapter, string pathItem) - { - int minimumIndex = 0; - var stepsPathItem = pathItem.Split('>').ToList(); - Ranorex.Row stepRow = argumentAdapter.As
().Rows.ToList()[1]; - for (int i=0; i < stepsPathItem.Count; i++) { - // Find the item corresponding to the step - var step = stepsPathItem[i]; - var completeList = argumentAdapter.As
().Rows.ToList(); - var searchList = completeList.GetRange(minimumIndex, completeList.Count-minimumIndex); - var indexStepRow = searchList.FindIndex(rw => rw.GetAttributeValue("AccessibleName").Contains(step)); - stepRow = searchList[indexStepRow]; - // if step is intermediate - if (i != stepsPathItem.Count - 1) - { - var stateStepRow = stepRow.Element.GetAttributeValueText("AccessibleState"); - // if intermediate step is collapsed - if (stateStepRow.Contains("Collapsed")) { - // Select and expand the intermediate item - Report.Log(ReportLevel.Info, "was collapsed"); - stepRow.Focus(); - stepRow.Select(); - stepRow.PressKeys("{Right}"); - } - } - else - { - // Select the final item - stepRow.Focus(); - stepRow.Select(); - } - // Update the minimum index administration (only search forward) - minimumIndex += 1 + indexStepRow; - } - return stepRow; - } - - - public void SetDoubleParameterInPropertiesPanel(Ranorex.Row row, string newValue) - { - //Convert string number from fixed culture of tables in Ranorex to double - // and then back to string using current culture - System.Globalization.CultureInfo fixedDataSourceCulture = new CultureInfo("en-US"); - fixedDataSourceCulture.NumberFormat.NumberDecimalSeparator = "."; - fixedDataSourceCulture.NumberFormat.NumberGroupSeparator = ""; - System.Globalization.CultureInfo currentCulture = CultureInfo.CurrentCulture; - newValue = Double.Parse(newValue, fixedDataSourceCulture).ToString(currentCulture); - // Assign converted value - row.Element.SetAttributeValue("AccessibleValue", newValue); - } - - public void SetTextParameterInPropertiesPanel(Ranorex.Row row, string newValue) - { - row.Element.SetAttributeValue("AccessibleValue", newValue); - } - - public void SetDynamicDropDownParameterInPropertiesPanel(Ranorex.Row row, string newValueForParameter, RepoItemInfo listItemInfo) - { - row.Click(); - row.Click(".98;.5"); - listItemInfo.FindAdapter().Focus(); - listItemInfo.FindAdapter().Click(); - } - - - /// + /// /// Constructs a new instance. /// public SetValueParameterInPropertiesPanelGivenPathTypeAndNewValue() @@ -137,30 +73,11 @@ /// that will in turn invoke this method. void ITestModule.Run() { - Mouse.DefaultMoveTime = 0; - Keyboard.DefaultKeyPressTime = 0; - Delay.SpeedFactor = 0.0; - - AutomatedSystemTestsRepository myRepository = global::AutomatedSystemTests.AutomatedSystemTestsRepository.Instance; Adapter propertiesPanelAdapter = myRepository.RiskeerMainWindow.ContainerMultipleViews.PropertiesPanelContainer.Table.Self; - Ranorex.Row row = GetRowInPropertiesPanelGivenPath(propertiesPanelAdapter, pathToElementInPropertiesPanel); - - switch (typeParameter) { - case "Text": - SetTextParameterInPropertiesPanel(row, newValueForParameter); - break; - case "Double": - SetDoubleParameterInPropertiesPanel(row, newValueForParameter); - break; - case "DropDown": - //RepoItemInfo listItemInfo = new RepoItemInfo(myRepository.DropDownMenuInRowPropertiesPanel.List, "genericItemInDropDownList", "listitem[@accessiblename~" + newValueForParameter + "]", 30000, null); - //SetDynamicDropDownParameterInPropertiesPanel(row, newValueForParameter, listItemInfo); - break; - default: - Report.Log(ReportLevel.Error, "Type of parameter " + typeParameter + " not implemented!"); - break; - } + + Ranorex.Row row = PropertiesPanelHelpers.GetRowInPropertiesPanelGivenPath(pathToElementInPropertiesPanel, propertiesPanelAdapter); + row.SetValue(newValueForParameter, typeParameter); } } } Index: System tests/AutomatedSystemTests/AutomatedSystemTests/Script20.rxtst =================================================================== diff -u -r35e1f5d8cc279c74a0d63d6cfb8916fe5d132ef4 -r811b4eb3c65fc8c315cb7e8a9fbb49a5c3d0b2c5 --- System tests/AutomatedSystemTests/AutomatedSystemTests/Script20.rxtst (.../Script20.rxtst) (revision 35e1f5d8cc279c74a0d63d6cfb8916fe5d132ef4) +++ System tests/AutomatedSystemTests/AutomatedSystemTests/Script20.rxtst (.../Script20.rxtst) (revision 811b4eb3c65fc8c315cb7e8a9fbb49a5c3d0b2c5) @@ -141,8 +141,8 @@ variablename="scriptOutputPath"> @@ -209,10 +209,6 @@ name="SelectFolderCalculations"> - - @@ -307,6 +303,7 @@ name="CloseView"> + value="IMPORTANT: The calculations for STPH and STBI are so fast that it is not possible to cancel them before they are finished. Therefore, they are not part of this script."> + + + + + + + + + + @@ -553,12 +572,6 @@ name="CalculatePathToResultItem"> - - @@ -627,6 +640,12 @@ + + @@ -663,6 +682,7 @@ + + + + + + - - + + + + + + + + + + - - @@ -1239,6 +1281,7 @@ + + @@ -1663,6 +1712,54 @@ variableid="4296aff0-7ef3-4132-ab64-c24e27efab2e" variablename="concatenatedString"> + + + + + + + + + + + + + + + + + + + + + + @@ -2016,6 +2123,10 @@ name="folderRiskeerProjectsPreviousRelease" value="X:\script20\previousRelease"> + + @@ -2061,14 +2172,6 @@ - - - - + + + + + + + + + + + + + + - - - - - - - - + + + + + + - - - - + nameFileToOpen + + + nameFileToSave + + timeToWaitBeforeCancelling @@ -2612,6 +2737,12 @@ pathToCalculationsInPE + + + + + + + + @@ -2665,9 +2814,15 @@ HTKW + + + + + +
+ nameFileToOpen + + nameFileToSave + timeToWaitBeforeCancelling @@ -2623,9 +2754,15 @@ STPH - Traject 12-2>Dijken en dammen - Piping>Berekeningen + Traject>Dijken en dammen - Piping>Berekeningen + script19a_STPH.risk + + script20_STPH.risk + 0 @@ -2637,9 +2774,15 @@ GEKB - Traject 12-2 (1)>Dijken en dammen - Grasbekleding erosie kruin en binnentalud>Berekeningen + Traject>Dijken en dammen - Grasbekleding erosie kruin en binnentalud>Berekeningen + script19a_GEKB.risk + + script20_GEKB.risk + 1000 @@ -2651,12 +2794,18 @@ STBI - 41-1>Dijken en dammen - Macrostabiliteit binnenwaarts>Berekeningen + Traject>Dijken en dammen - Macrostabiliteit binnenwaarts>Berekeningen - 100 + script19a_STBI.risk + script20_STBI.risk + + 0 + 24-31
- 36-2>Kunstwerken - Hoogte kunstwerk>Berekeningen + Traject>Kunstwerken - Hoogte kunstwerk>Berekeningen + script19a_HTKW.risk + + script20_HTKW.risk + 1000 @@ -2679,9 +2834,15 @@ BSKW - 34-1>Kunstwerken - Betrouwbaarheid sluiting kunstwerk>Berekeningen + Traject>Kunstwerken - Betrouwbaarheid sluiting kunstwerk>Berekeningen + script19a_BSKW.risk + + script20_BSKW.risk + 1000 @@ -2693,9 +2854,15 @@ STKWp - 44-2>Kunstwerken - Sterkte en stabiliteit puntconstructies>Berekeningen + Traject>Kunstwerken - Sterkte en stabiliteit puntconstructies>Berekeningen + script19a_STKWp.risk + + script20_STKWp.risk + 1000 @@ -4335,174 +4502,36 @@ id="12f522a3-ac39-4cce-824b-9e10160dc9f6"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + id="ff975747-306b-4cfe-8fd4-eb3fb0de1826"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: System tests/AutomatedSystemTests/RanorexAutomationHelpers/Ranorex Automation Helpers.csproj =================================================================== diff -u -rce55d0e55e5ba5677e7913b3a343dd82b420a1b5 -r811b4eb3c65fc8c315cb7e8a9fbb49a5c3d0b2c5 --- System tests/AutomatedSystemTests/RanorexAutomationHelpers/Ranorex Automation Helpers.csproj (.../Ranorex Automation Helpers.csproj) (revision ce55d0e55e5ba5677e7913b3a343dd82b420a1b5) +++ System tests/AutomatedSystemTests/RanorexAutomationHelpers/Ranorex Automation Helpers.csproj (.../Ranorex Automation Helpers.csproj) (revision 811b4eb3c65fc8c315cb7e8a9fbb49a5c3d0b2c5) @@ -164,6 +164,9 @@ afe1cf19-2183-4309-89af-5d4e51978cff + + fb68c730-3ebf-4e22-8803-3b13d32eb2f8 + 571af684-5135-4bc5-93ac-b66f3f0fd03c Index: System tests/AutomatedSystemTests/RanorexAutomationHelpers/UserCodeCollections/PropertiesPanelHelpers.cs =================================================================== diff -u --- System tests/AutomatedSystemTests/RanorexAutomationHelpers/UserCodeCollections/PropertiesPanelHelpers.cs (revision 0) +++ System tests/AutomatedSystemTests/RanorexAutomationHelpers/UserCodeCollections/PropertiesPanelHelpers.cs (revision 811b4eb3c65fc8c315cb7e8a9fbb49a5c3d0b2c5) @@ -0,0 +1,108 @@ +/* + * Created by Ranorex + * User: rodriqu_dd + * Date: 01/11/2021 + * Time: 09:11 + * + * To change this template use Tools > Options > Coding > Edit standard headers. + */ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using System.Drawing; +using System.Threading; +using System.Linq; +using WinForms = System.Windows.Forms; + +using Ranorex; +using Ranorex.Core; +using Ranorex.Core.Repository; +using Ranorex.Core.Testing; + +namespace Ranorex_Automation_Helpers.UserCodeCollections +{ + /// + /// Creates a Ranorex user code collection. A collection is used to publish user code methods to the user code library. + /// + [UserCodeCollection] + public static class PropertiesPanelHelpers + { + // You can use the "Insert New User Code Method" functionality from the context menu, + // to add a new method with the attribute [UserCodeMethod]. + + /// + /// This static method returns a Row object given the path in the properties panel. + /// + [UserCodeMethod] + public static Ranorex.Row GetRowInPropertiesPanelGivenPath(string pathItem, Adapter argumentAdapter) + { + Mouse.DefaultMoveTime = 0; + Keyboard.DefaultKeyPressTime = 0; + Delay.SpeedFactor = 0.0; + int minimumIndex = 0; + var stepsPathItem = pathItem.Split('>').ToList(); + Ranorex.Row stepRow = argumentAdapter.As().Rows.ToList()[1]; + for (int i=0; i < stepsPathItem.Count; i++) + { + // Find the item corresponding to the step + var step = stepsPathItem[i]; + var completeList = argumentAdapter.As
().Rows.ToList(); + var searchList = completeList.GetRange(minimumIndex, completeList.Count-minimumIndex); + var indexStepRow = searchList.FindIndex(rw => rw.GetAttributeValue("AccessibleName").Contains(step)); + stepRow = searchList[indexStepRow]; + stepRow.Focus(); + stepRow.Select(); + if (i != stepsPathItem.Count - 1 && stepRow.Element.GetAttributeValueText("AccessibleState").Contains("Collapsed")) + { + stepRow.PressKeys("{Right}"); + } + minimumIndex += 1 + indexStepRow; + } + return stepRow; + } + + + /// + /// This method sets a new value to a parameter in a field in properties panel given its path. + /// + [UserCodeMethod] + public static void SetValue(this Ranorex.Row row, string newValue, string parameterType) + { + switch (parameterType) { + case "Text": + SetTextParameterInPropertiesPanel(row, newValue); + break; + case "Double": + SetDoubleParameterInPropertiesPanel(row, newValue); + break; + case "DropDown": + //RepoItemInfo listItemInfo = new RepoItemInfo(myRepository.DropDownMenuInRowPropertiesPanel.List, "genericItemInDropDownList", "listitem[@accessiblename~" + newValueForParameter + "]", 30000, null); + //SetDynamicDropDownParameterInPropertiesPanel(row, newValueForParameter, listItemInfo); + break; + default: + Report.Log(ReportLevel.Error, "Type of parameter " + parameterType + " not implemented!"); + break; + } + } + + private static void SetDoubleParameterInPropertiesPanel(Ranorex.Row row, string newValue) + { + row.Element.SetAttributeValue("AccessibleValue", newValue.ToCurrentCulture()); + } + + private static void SetTextParameterInPropertiesPanel(Ranorex.Row row, string newValue) + { + row.Element.SetAttributeValue("AccessibleValue", newValue); + } + + private static void SetDynamicDropDownParameterInPropertiesPanel(Ranorex.Row row, string newValueForParameter, RepoItemInfo listItemInfo) + { + row.Click(); + row.Click(".98;.5"); + listItemInfo.FindAdapter().Focus(); + listItemInfo.FindAdapter().Click(); + } + + } +}