public void TheQuickAddStockAdjustmentTest(string comment, string products)
        {
            navigation.Replenishment.Click();
            navigation.StockAdjustment.Click();
            Thread.Sleep(2000);

            StockAdjustmentPageModel stockAdjust = new StockAdjustmentPageModel(driver);
            for (int i = 0; ; i++)
            {
                if (i >= 60) Assert.Fail("timeout");
                try
                {
                    if (stockAdjust.StockAdjustFrame.Displayed) break;
                }
                catch (Exception) { }
                Thread.Sleep(1000);
            }

            driver.SwitchTo().Frame(stockAdjust.StockAdjustFrame);
            stockAdjust.NewStockAdjust.Click();
            driver.SwitchTo().DefaultContent();
            NewStockAdjustmentPageModel newSA = new NewStockAdjustmentPageModel(driver);
            for (int i = 0; ; i++)
            {
                if (i >= 60) Assert.Fail("timeout");
                try
                {
                    if (newSA.NewStockAdjustFrame.Displayed) break;
                }
                catch (Exception) { }
                Thread.Sleep(1000);
            }
            driver.SwitchTo().Frame(newSA.NewStockAdjustFrame);
            new SelectElement(newSA.NewStockAdjustReason).SelectByText("Damaged");
            newSA.NewStockAdjustComments.SendKeys("Automated " + comment);

            Thread.Sleep(2000);
            string[] productList = config[products].Split(',');
            Random rand = new Random();
            foreach (string prod in productList)
            {
                newSA.NewStockAdjustQuickAddTxt.SendKeys(prod);
                newSA.NewStockAdjustQuickAddButton.Click();
                for (int i = 0; ; i++)
                {
                    if (i >= 60) Assert.Fail("timeout");
                    try
                    {
                        if (newSA.NewStockAdjustQuickAddQty.Displayed) break;
                    }
                    catch (Exception) { }
                    Thread.Sleep(1000);
                }
                newSA.NewStockAdjustQuickAddQty.SendKeys(rand.Next(1, 11).ToString());
                newSA.NewStockAdjustQuickAddQty.SendKeys(Keys.Enter);
                //driver.SwitchTo().DefaultContent();

                //driver.SwitchTo().Frame(newSA.NewStockAdjustFrame);
                Thread.Sleep(3000);
            }
            newSA.SaveStockAdjust.Click();
            driver.SwitchTo().DefaultContent();
            for (int i = 0; ; i++)
            {
                if (i >= 60) Assert.Fail("timeout");
                try
                {
                    if (stockAdjust.StockAdjustFrame.Displayed) break;
                }
                catch (Exception) { }
                Thread.Sleep(1000);
            }

            Logout();
        }
        public void TheAdvancedSearchStockAdjustmentTest(string comment, string products)
        {
            navigation.Replenishment.Click();
            navigation.StockAdjustment.Click();
            Thread.Sleep(2000);

            StockAdjustmentPageModel stockAdjust = new StockAdjustmentPageModel(driver);
            for (int i = 0; ; i++)
            {
                if (i >= 60) Assert.Fail("timeout");
                try
                {
                    if (stockAdjust.StockAdjustFrame.Displayed) break;
                }
                catch (Exception) { }
                Thread.Sleep(1000);
            }

            driver.SwitchTo().Frame(stockAdjust.StockAdjustFrame);
            stockAdjust.NewStockAdjust.Click();
            driver.SwitchTo().DefaultContent();
            NewStockAdjustmentPageModel newSA = new NewStockAdjustmentPageModel(driver);
            for (int i = 0; ; i++)
            {
                if (i >= 60) Assert.Fail("timeout");
                try
                {
                    if (newSA.NewStockAdjustFrame.Displayed) break;
                }
                catch (Exception) { }
                Thread.Sleep(1000);
            }
            driver.SwitchTo().Frame(newSA.NewStockAdjustFrame);
            new SelectElement(newSA.NewStockAdjustReason).SelectByText("Damaged");
            newSA.NewStockAdjustComments.SendKeys("Automated " + comment);

            Thread.Sleep(2000);
            string[] productList = config[products].Split(',');
            AdvancedSearchPageModel advancedSearch = new AdvancedSearchPageModel(driver);
            Random rand = new Random();
            foreach (string prod in productList)
            {
                newSA.NewStockAdjustAdvancedSearch.Click();
                for (int i = 0; ; i++)
                {
                    if (i >= 60) Assert.Fail("timeout");
                    try
                    {
                        if (advancedSearch.AdvancedSearchFrame.Displayed) break;
                    }
                    catch (Exception) { }
                    Thread.Sleep(1000);
                }
                driver.SwitchTo().Frame(advancedSearch.AdvancedSearchFrame);
                advancedSearch.ItemCode.SendKeys(prod);

                advancedSearch.SearchButton.Click();
                for (int i = 0; ; i++)
                {
                    if (i >= 60) Assert.Fail("timeout");
                    try
                    {
                        if (advancedSearch.SelectAll.Enabled) break;
                    }
                    catch (Exception) { }
                    Thread.Sleep(1000);
                }

                new Actions(driver).DoubleClick(newSA.AdvancedSearchAdjustQuantityActivate).Build().Perform();
                newSA.AdvancedSearchAdjustQuantity.SendKeys(rand.Next(1, 11).ToString());
                newSA.AdvancedSearchAdjustQuantity.SendKeys(Keys.Enter);
                Thread.Sleep(1000);
                //shared.WaitForElementNotAppear(driver, driver.FindElement(By.ClassName("blockUI")));
                advancedSearch.OKButton.Click();
                driver.SwitchTo().DefaultContent();
                driver.SwitchTo().Frame(newSA.NewStockAdjustFrame);
                Thread.Sleep(2000);
            }

            newSA.SaveStockAdjust.Click();
            driver.SwitchTo().DefaultContent();

            for (int i = 0; ; i++)
            {
                if (i >= 60) Assert.Fail("timeout");
                try
                {
                    if (stockAdjust.StockAdjustFrame.Displayed) break;
                }
                catch (Exception) { }
                Thread.Sleep(1000);
            }
            Logout();
        }