Example #1
0
        public void Test_C_0_FetchPackagePrices()
        {
            // TESTparameters: Test_H_FetchPackagePrices

            string role               = "Test Package Pricer";
            string mainGroup          = "00 - General";
            string subGroup           = "00 - Vehicle, complete";
            string vehicleType        = "All Scania Vehicles";
            string variantDescription = "VariantDescription";
            string reasonForPackage   = "ReasonForPackage";
            string packageName        = "PackageToManage";
            string packageDescription = "PackageDescription";
            string workorderText      = "WorkorderText";
            string invoiceText        = "InvoiceText";
            string parts              = "1110055";
            string labour             = "01015111";
            string sundry             = "18";
            string approval           = "GLOBAL\\testfprpricer (FPRPRICER IWNP)";
            string packageStatus      = "SENT FOR REVIEW";

            // ---------------------------------------------------------

            LoginPage.LoginAs(role);
            verifyPageTitle(HomePage.mainPageTitle, driver);

            // Navigate Packages -> Create
            HomePage.menuPackages.Click();

            // Wait for page to load
            WaitForAjax(driver, 10, true);

            // Click on menu "Create"
            HomePage.menuCreate.Click();

            //Click on button Next
            WaitForElement(SearchPage.buttonNext);
            SearchPage.buttonNext.Click();

            // Fill out description form
            WaitForElement(DescriptionPage.listMainGroup);
            DescriptionPage.ToFillOutDescription(mainGroup, subGroup, vehicleType, variantDescription, reasonForPackage, packageName, packageDescription, workorderText, invoiceText);

            // Click button Next
            DescriptionPage.buttonNext.Click();

            // Fill out content form
            WaitForElements(ContentPage.allDropDownLists);
            ContentPage.ChoosePartLabourAndSundry(parts, labour, sundry);

            WaitForElement(ContentPage.checkbox_MAIN_PART);
            ContentPage.checkbox_MAIN_PART.Click();

            // Click button Next
            DescriptionPage.buttonNext.Click();

            Thread.Sleep(3000);

            PreviewPage.buttonApprove.Click();

            Thread.Sleep(3000);

            PreviewPage.buttonApproveOnConfirmationDialog.Click();

            Thread.Sleep(3000);

            PreviewPage.buttonNext.Click();

            Thread.Sleep(3000);

            // Find and click on the market
            PricingPage.ToFindMarket("Sweden");

            Thread.Sleep(3000);

            PricingPage.buttonPriceForGroup();

            Thread.Sleep(3000);

            WaitForElements(PricingPage.listWithDiscountButtons);

            PricingPage.buttonOpenListWithParts.Click();

            Thread.Sleep(3000);

            // Set discount
            PricingPage.ToSetDiscountPercentage(5.ToString());

            WaitForAjax(driver, 2, true);

            // Fetch all fields
            double QTY         = Convert.ToDouble(PricingPage.fieldQuantity.Text);
            double CostPrice   = PricingPage.ToDouble(PricingPage.fieldCost);
            double RetailPrice = PricingPage.ToDouble(PricingPage.fieldRetailPrice);
            //  + discountPercentage
            double SalesNetPrice         = PricingPage.ToDouble(PricingPage.fieldSalesNetPrice);
            double TotalCost             = PricingPage.ToDouble(PricingPage.fieldTotalCost);
            double TotalGross            = PricingPage.ToDouble(PricingPage.fieldTotalGross);
            double TotalNet              = PricingPage.ToDouble(PricingPage.fieldTotalNet);
            double GrossProfitAmount     = PricingPage.ToDouble(PricingPage.fieldGrossProfitAmount);
            double GrossProfitPercentage = PricingPage.ToDouble(PricingPage.fieldGrossProfitPercentage);


            // Write to excel file
            WriteToExcel = new WriteToExcel();

            double[] data = new double[10] {
                QTY,
                CostPrice,
                RetailPrice,
                5,
                SalesNetPrice,
                TotalCost,
                TotalGross,
                TotalNet,
                GrossProfitAmount,
                GrossProfitPercentage
            };

            WriteToExcel.WriteToRange("CalculationData", data, "A2", "J2");
        }
        public void CreateFileWithTestData()
        {
            Driver getDriver = new Driver();

            driver = getDriver.driverChrome();

            LoginPage       = new LoginPage(driver);
            HomePage        = new HomePage(driver);
            DescriptionPage = new DescriptionPage(driver);
            ManagePackages  = new ManagePackages(driver);
            ContentPage     = new ContentPage(driver);
            PreviewPage     = new PreviewPage(driver);
            SearchPage      = new SearchPage(driver);
            PackagesMenu    = new PackagesMenu(driver);
            PricingPage     = new PricingPage(driver);
            CleanData       = new CleanData();
            ApprovePage     = new ApprovePage(driver);

            driver.Navigate().GoToUrl(URL);

            // CreatePackage_AddTwoParts_Approve_SetDiscount_ExportToExcel

            string role               = "Test Package Pricer";
            string mainGroup          = "00 - General";
            string subGroup           = "00 - Vehicle, complete";
            string vehicleType        = "All Scania Vehicles";
            string variantDescription = "VariantDescription";
            string reasonForPackage   = "ReasonForPackage";
            string packageName        = "PackagePriceTwoParts";
            string packageDescription = "PackageDescription";
            string workorderText      = "WorkorderText";
            string invoiceText        = "InvoiceText";
            string parts              = "1110055";
            string quantity           = "2";

            // ---------------------------------------------------------

            LoginPage.LoginAsRealUser();
            verifyPageTitle(HomePage.mainPageTitle, driver);

            // Navigate Packages -> Create
            HomePage.menuPackages.Click();

            // Wait for page to load
            WaitForAjax(driver, 10, true);

            // Click on menu "Create"
            HomePage.menuCreate.Click();

            //Click on button Next
            WaitForElement(SearchPage.buttonNext);
            SearchPage.buttonNext.Click();

            // Fill out description form
            WaitForElement(DescriptionPage.listMainGroup);
            DescriptionPage.ToFillOutDescription(mainGroup, subGroup, vehicleType, variantDescription, reasonForPackage, packageName, packageDescription, workorderText, invoiceText);

            // Click button Next
            DescriptionPage.buttonNext.Click();

            // Choose a part
            WaitForElements(ContentPage.allDropDownLists);
            ContentPage.dropDownSelectPart(parts);
            ContentPage.buttonAddParts.Click();

            // Set quantity
            ContentPage.fieldQty.Clear();
            ContentPage.fieldQty.SendKeys(quantity);

            // Select main part
            WaitForElement(ContentPage.checkbox_MAIN_PART);
            ContentPage.checkbox_MAIN_PART.Click();

            // Click button Next
            DescriptionPage.buttonNext.Click();

            Thread.Sleep(3000);
            PreviewPage.buttonApprove.Click();

            Thread.Sleep(3000);
            PreviewPage.buttonApproveOnConfirmationDialog.Click();

            Thread.Sleep(3000);
            PreviewPage.buttonNext.Click();

            Thread.Sleep(3000);

            // Find and click on the market
            PricingPage.ToFindMarket("Sweden");

            Thread.Sleep(3000);
            PricingPage.buttonPriceForGroup();

            Thread.Sleep(3000);
            WaitForElements(PricingPage.listWithDiscountButtons);

            PricingPage.buttonOpenListWithParts.Click();
            Thread.Sleep(3000);

            // Set discount
            PricingPage.ToSetDiscountPercentage(5.ToString());

            Thread.Sleep(5000);

            WaitForAjax(driver, 2, true);

            driver.FindElement(By.CssSelector("[value=\"Export to Excel\"]")).Click();

            driver.Close();
            driver.Quit();



            ReadFromExcel getDataSource = new ReadFromExcel();
            List <string> dataArray     = getDataSource.GetWorkSheet(pathToFileWithTestData, 1, "A3", "S3");

            qty                               = ToDouble(dataArray[4]);
            cost                              = ToDouble(dataArray[5]);
            distributorCost                   = ToDouble(dataArray[6]);
            retailPrice                       = ToDouble(dataArray[7]);
            discount_Amount                   = ToDouble(dataArray[8]);
            discount_Percentage               = ToDouble(dataArray[9]);
            salesNetPrice                     = ToDouble(dataArray[10]);
            totalNet                          = ToDouble(dataArray[11]);
            totalGross                        = ToDouble(dataArray[12]);
            totalCost                         = ToDouble(dataArray[13]);
            grossProfit_Amount                = ToDouble(dataArray[14]);
            grossProfit_Percentage            = ToDouble(dataArray[15]);
            totalCostDistributor              = ToDouble(dataArray[16]);
            grossProfitDistributor_Amount     = ToDouble(dataArray[17]);
            grossProfitDistributor_Percentage = ToDouble(dataArray[18]);
        }