예제 #1
0
        public void SetOperationDetails(Field el, OperationWithValues operation, ReportPage _reportPage)
        {
            if (operation.Type != OperationType.None)
            {
                switch (el.Filter)
                {
                case FilterTypes.Input:
                    _reportPage.InputField(el.Name).Clear();
                    _reportPage.InputField(el.Name).SendKeys(operation.ValueToUse);

                    break;

                case FilterTypes.AutoComplete:
                    _reportPage.InputWithAutoCompleteField(el.Name).Clear();
                    _reportPage.InputWithAutoCompleteField(el.Name).Click();
                    Console.WriteLine(operation.ValueToUse);
                    if (operation.ValueToUse.Length >= 4)
                    {
                        _reportPage.InputWithAutoCompleteField(el.Name).SendKeys(operation.ValueToUse.Substring(0, 4));
                    }
                    else
                    {
                        _reportPage.InputWithAutoCompleteField(el.Name).SendKeys(operation.ValueToUse);
                    }
                    _reportPage.InputWithAutoCompleteField(el.Name).Click();
                    _reportPage.SelectFromList(operation.ValueToUse).Click();

                    break;

                case FilterTypes.Date:
                    _reportPage.InputField(el.Name).Click();
                    _reportPage.InputField(el.Name).Clear();
                    _reportPage.InputField(el.Name).SendKeys(operation.StartDate.ToString());
                    _reportPage.InputField(el.Name).SendKeys(Keys.Enter);
                    _reportPage.Body.Click();
                    if (operation.Type == OperationType.Between)
                    {
                        _reportPage.AddFilter.Click();
                        _reportPage.Body.Click();
                        _reportPage.EndDateField(el.Name).Click();
                        _reportPage.EndDateField(el.Name).Clear();
                        _reportPage.EndDateField(el.Name).SendKeys(operation.EndDate.ToString());
                        _reportPage.Body.Click();
                    }
                    _driver.FindElement(By.XPath("*//span[text() = 'Apply']")).Click();

                    break;

                case FilterTypes.Select:
                    _reportPage.SelectField(el.Name).Click();
                    _reportPage.SelectFromListForFilter(operation.ValueToUse);
                    break;

                default:
                    break;
                }
            }
        }