Exemplo n.º 1
0
        public void Setup()
        {
            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);
            ImportPage      = new ImportPage(driver);

            driver.Navigate().GoToUrl(URL);
        }
        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]);
        }