Пример #1
0
        /// <summary>
        /// Gets all values from Concentration table within Liquid properties and stores them in a list. This will only work if you selected List as input form.
        /// </summary>
        /// <returns>List with all table values.</returns>
        public List <string> AllValues()
        {
            var result = new List <string>();

            var list = new LiquidPropertiesElements().TableCells;

            foreach (Element cell in list)
            {
                if (cell.GetAttributeValueText("AccessibleName").Contains(";0") || cell.GetAttributeValueText("AccessibleName").Contains(";1") || cell.GetAttributeValueText("AccessibleName").Contains(";2"))
                {
                    result.Add(cell.GetAttributeValueText("AccessibleValue"));
                }
            }

            if (result.Count == 0)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Failed to store values in list.");
            }
            else
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Finished storing table values in list");
            }

            return(result);
        }
        /// <summary>
        ///     Fills list with random numbers between 0-100
        /// </summary>
        public void FillList()
        {
            var     rand             = new Random();
            Element tableGridControl = new LiquidPropertiesElements().TableGridControl;

            // Click in the center of grid control to activate edit fields, then move cursor to first field via keyboard
            Mouse.Click(tableGridControl);
            for (int i = 0; i < 6; i++)
            {
                Keyboard.Press(Keys.Up);
            }

            Keyboard.Press(Keys.Left);

            /*
             * Set the first value and confirm it with enter, then go to the second field (this is needed to "activate" the 11th row in the table,
             * otherwise, if not confirmed with enter, only 10 rows are shown and the table cannot be filled correctly
             */
            Keyboard.Press(rand.Next(0, 100).ToString(CultureInfo.InvariantCulture));
            Keyboard.Press(Keys.Enter);
            Keyboard.Press(Keys.Right);
            Keyboard.Press(Keys.Enter);

            // fill the other 32 field with random numbers and confirm with enter
            for (int i = 2; i < 34; i++)
            {
                Keyboard.Press(rand.Next(0, 100).ToString(CultureInfo.InvariantCulture));
                Keyboard.Press(Keys.Tab);
            }

            Keyboard.Press(Keys.Enter);
        }
Пример #3
0
        ///// <summary>
        ///// Sets all table values provided from a list.
        ///// </summary>
        ///// <param name="inputValues">
        ///// The input values.
        ///// </param>
        ///// <returns>
        ///// <c>true</c> if values have been set, <c>false</c> otherwise.
        ///// </returns>
        ////public bool SetValues(List<string> inputValues)
        ////{
        ////    if (inputValues.Count % 3 != 0)
        ////    {
        ////        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Your list has an odd number of values. Please use an even number of values.");
        ////        return false;
        ////    }

        ////    Cell firstCell = new LiquidPropertiesElements().TableCell(0, 0);
        ////    firstCell.Click(500);
        ////    int firstX = Mouse.Position.X;
        ////    int firstY = Mouse.Position.Y;

        ////    Cell secondCell = new LiquidPropertiesElements().TableCell(0, 1);
        ////    secondCell.Click(500);
        ////    int secondX = Mouse.Position.X;
        ////    int secondY = Mouse.Position.Y;

        ////    Cell thirdCell = new LiquidPropertiesElements().TableCell(0, 2);
        ////    thirdCell.Click(500);
        ////    int thirdX = Mouse.Position.X;
        ////    int thirdY = Mouse.Position.Y;

        ////    Mouse.MoveTo(firstX, firstY, 500);
        ////    Mouse.Click();

        ////    for (int counter = 0; counter < inputValues.Count / 3; counter++)
        ////    {
        ////        Keyboard.Press(inputValues[(counter * 3)]);
        ////        Keyboard.Press(Keys.Down);
        ////        if (counter > 7)
        ////        {
        ////            Keyboard.Press(Keys.Down);
        ////        }
        ////    }

        ////    Mouse.MoveTo(secondX, secondY, 500);
        ////    Mouse.Click();

        ////    for (int counter = 0; counter < inputValues.Count / 3; counter++)
        ////    {
        ////        Keyboard.Press(inputValues[(counter * 3) + 1]);
        ////        Keyboard.Press(Keys.Down);
        ////    }

        ////    Mouse.MoveTo(thirdX, thirdY, 500);
        ////    Mouse.Click();

        ////    for (int counter = 0; counter < inputValues.Count / 3; counter++)
        ////    {
        ////        Keyboard.Press(inputValues[(counter * 3) + 2]);
        ////        Keyboard.Press(Keys.Down);
        ////    }

        ////    Keyboard.Press(Keys.Up);

        ////    return true;
        ////}
        #region Public Methods and Operators

        /// <summary>
        /// Sets all table values provided from a list.
        /// </summary>
        /// <param name="inputValues">
        /// The input values.
        /// </param>
        /// <returns>
        /// <c>true</c> if values have been set, <c>false</c> otherwise.
        /// </returns>
        public bool SetValues(List <string> inputValues)
        {
            if (inputValues.Count % 3 != 0)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Your list has an odd number of values. Please use an even number of values.");
                return(false);
            }

            Cell firstCell = new LiquidPropertiesElements().TableCell(0, 0);

            firstCell.DoubleClick(500);

            for (int counter = 0; counter < inputValues.Count / 3; counter++)
            {
                Keyboard.Press(inputValues[counter * 3]);
                Keyboard.Press(Keys.Enter);
                if (counter > 7)
                {
                    Keyboard.Press(Keys.Enter);
                    Keyboard.Press(Keys.Enter);
                }

                Thread.Sleep(500);
            }

            Keyboard.Press(Keys.Right);

            for (int i = 0; i < inputValues.Count / 3; i++)
            {
                Keyboard.Press(Keys.Up);
            }

            for (int counter = 0; counter < inputValues.Count / 3; counter++)
            {
                Keyboard.Press(inputValues[(counter * 3) + 1]);
                Keyboard.Press(Keys.Enter);
                Thread.Sleep(500);
            }

            Keyboard.Press(Keys.Right);

            for (int i = 0; i < inputValues.Count / 3; i++)
            {
                Keyboard.Press(Keys.Up);
            }

            for (int counter = 0; counter < inputValues.Count / 3; counter++)
            {
                Keyboard.Press(inputValues[(counter * 3) + 2]);
                Keyboard.Press(Keys.Enter);
                Thread.Sleep(500);
            }

            return(true);
        }
Пример #4
0
        /// <summary>
        /// The recalculate.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Recalculate()
        {
            Element element = new LiquidPropertiesElements().ButtonRecalculate;

            if (element != null)
            {
                Mouse.Click(element);
                return(true);
            }

            return(false);
        }
Пример #5
0
        /// <summary>
        /// Returns the value for a specified row and column
        /// </summary>
        /// <param name="row">
        /// The row.
        /// </param>
        /// <param name="column">
        /// The column.
        /// </param>
        /// <returns>
        /// The value for the row and column.
        /// </returns>
        public string SingleValue(int row, int column)
        {
            string result = string.Empty;

            var list = new LiquidPropertiesElements().TableCells;

            foreach (Element cell in list)
            {
                if (cell.GetAttributeValueText("AccessibleName") == (row - 1) + ";" + (column - 1))
                {
                    result = cell.GetAttributeValueText("AccessibleValue");
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Value for row " + row + " column " + column + " = " + result);
                    break;
                }
            }

            if (result == string.Empty)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Failed to get value for row " + row + " column " + column);
            }

            return(result);
        }
Пример #6
0
        ///// <summary>
        ///// Sets all table values provided from a list.
        ///// </summary>
        ///// <param name="inputValues">
        ///// The input values.
        ///// </param>
        ///// <returns>
        ///// <c>true</c> if values have been set, <c>false</c> otherwise.
        ///// </returns>
        ////public bool SetValues(List<string> inputValues)
        ////{
        ////    if (inputValues.Count % 3 != 0)
        ////    {
        ////        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Your list has an odd number of values. Please use an even number of values.");
        ////        return false;
        ////    }

        ////    Cell firstCell = new LiquidPropertiesElements().TableCell(0, 0);
        ////    firstCell.Click(500);
        ////    int firstX = Mouse.Position.X;
        ////    int firstY = Mouse.Position.Y;

        ////    Cell secondCell = new LiquidPropertiesElements().TableCell(0, 1);
        ////    secondCell.Click(500);
        ////    int secondX = Mouse.Position.X;
        ////    int secondY = Mouse.Position.Y;

        ////    Cell thirdCell = new LiquidPropertiesElements().TableCell(0, 2);
        ////    thirdCell.Click(500);
        ////    int thirdX = Mouse.Position.X;
        ////    int thirdY = Mouse.Position.Y;

        ////    Mouse.MoveTo(firstX, firstY, 500);
        ////    Mouse.Click();

        ////    for (int counter = 0; counter < inputValues.Count / 3; counter++)
        ////    {
        ////        Keyboard.Press(inputValues[(counter * 3)]);
        ////        Keyboard.Press(Keys.Down);
        ////        if (counter > 7)
        ////        {
        ////            Keyboard.Press(Keys.Down);
        ////        }
        ////    }

        ////    Mouse.MoveTo(secondX, secondY, 500);
        ////    Mouse.Click();

        ////    for (int counter = 0; counter < inputValues.Count / 3; counter++)
        ////    {
        ////        Keyboard.Press(inputValues[(counter * 3) + 1]);
        ////        Keyboard.Press(Keys.Down);
        ////    }

        ////    Mouse.MoveTo(thirdX, thirdY, 500);
        ////    Mouse.Click();

        ////    for (int counter = 0; counter < inputValues.Count / 3; counter++)
        ////    {
        ////        Keyboard.Press(inputValues[(counter * 3) + 2]);
        ////        Keyboard.Press(Keys.Down);
        ////    }

        ////    Keyboard.Press(Keys.Up);

        ////    return true;
        ////}
        #region Public Methods and Operators

        /// <summary>
        /// Sets all table values provided from a list.
        /// </summary>
        /// <param name="inputValues">
        /// The input values.
        /// </param>
        /// <returns>
        /// <c>true</c> if values have been set, <c>false</c> otherwise.
        /// </returns>
        public bool SetValues(List <string> inputValues)
        {
            if (inputValues != null)
            {
                if (inputValues.Count > 0)
                {
                    if (inputValues.Count % 3 != 0)
                    {
                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Your list has an odd number of values. Please use an even number of values.");
                        return(false);
                    }

                    Ranorex.Core.Element firstCell = new LiquidPropertiesElements().TableCell(0, 0);

                    if (firstCell != null)
                    {
                        Mouse.MoveTo(firstCell, new Location(20, 5), 500);
                        Mouse.DoubleClick();

                        for (int counter = 0; counter < inputValues.Count / 3; counter++)
                        {
                            Keyboard.Press(inputValues[counter * 3]);

                            // 2017-09-27 - EC: Workaround um das Tabellenhandlich zu kompensieren.
                            Keyboard.Press(Keys.Down);
                            Thread.Sleep(500);
                        }

                        Keyboard.Press(Keys.Right);

                        for (int i = 0; i < inputValues.Count / 3; i++)
                        {
                            Keyboard.Press(Keys.Up);
                            Thread.Sleep(200);
                        }

                        for (int counter = 0; counter < inputValues.Count / 3; counter++)
                        {
                            Keyboard.Press(inputValues[(counter * 3) + 1]);
                            Keyboard.Press(Keys.Down);
                            Thread.Sleep(200);
                        }

                        Keyboard.Press(Keys.Right);

                        for (int i = 0; i < inputValues.Count / 3; i++)
                        {
                            Keyboard.Press(Keys.Up);
                            Thread.Sleep(200);
                        }

                        for (int counter = 0; counter < inputValues.Count / 3; counter++)
                        {
                            Keyboard.Press(inputValues[(counter * 3) + 2]);
                            Keyboard.Press(Keys.Down);
                            Thread.Sleep(200);
                        }

                        Keyboard.Press(Keys.Up);

                        return(true);
                    }

                    Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Table not found");
                    return(false);
                }

                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Number of input values is 0");
                return(false);
            }

            Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "No input values available");
            return(false);
        }