/// <summary>
        /// Verifies Po Posting with CBL1.
        /// </summary>
        /// <param name="qatoolsTargetUrl"></param>
        /// <param name="fileName"></param>
        /// <param name="poRefNum"></param>
        /// <param name="identityName"></param>
        /// <param name="supplierPartIdExt"></param>
        /// <param name="unitPrice"></param>
        /// <param name="quantity"></param>
        public string VerifyPoPosting(string qatoolsTargetUrl, string fileName, string poRefNum,
                                      string identityName, string supplierPartIdExt, string unitPrice, string quantity)
        {
            //uniquePoRefNum = poRefNum + DateTime.Today.ToString("yyMMdd") + DateTime.Now.ToString("HHmmss");
            uniquePoRefNum = poRefNum + DateTime.Now.ToString("ffffff");
            B2BQaToolsPage = new B2BQaToolsPage(webDriver);
            B2BQaToolsPage.PasteTargetUrl(qatoolsTargetUrl);
            var file = PoXmlGenerator.GeneratePoCblwithoutCrt(fileName, uniquePoRefNum, identityName, supplierPartIdExt,
                                                              unitPrice, quantity);

            B2BQaToolsPage.PasteInputXml(file);
            webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMinutes(2));
            B2BQaToolsPage.ClickSubmitMessage();
            if (B2BQaToolsPage.GetSubmissionResult().Equals("XML Response received from server Code: 200. Message: PO = " + uniquePoRefNum))
            {
                Console.WriteLine("Success: PO Number: " + uniquePoRefNum);
                return(uniquePoRefNum);
            }
            else
            {
                Console.WriteLine("Error while posting PO: " + B2BQaToolsPage.GetSubmissionResult());
                Console.WriteLine("Fail: PO Number: " + uniquePoRefNum);
                throw new Exception("Error while posting PO: " + uniquePoRefNum);
            }
        }
        /// <summary>
        /// Verifies Po Posting with CBL3.
        /// </summary>
        /// <param name="qatoolsTargetUrl"></param>
        /// <param name="fileName"></param>
        /// <param name="poRefNum"></param>
        /// <param name="identityName"></param>
        /// <param name="supplierPartIdExt"></param>
        /// <param name="unitPrice"></param>
        /// <param name="quantity"></param>
        public string VerifyDownloadAndPoPostingwithCxml(B2BEnvironment environment, CatalogItemType itemType, CatalogType type, CatalogStatus status, Region region, CRTStatus crtStatus,
                                                         string fileName, string poRefNum, string profileName, string identityName, string quantity)
        {
            //uniquePoRefNum = poRefNum + DateTime.Today.ToString("yyMMdd") + DateTime.Now.ToString("HHmmss");
            uniquePoRefNum = poRefNum + DateTime.Now.ToString("ffffff");
            ChannelCatalogWorkflow uxWorkFlow = new ChannelCatalogWorkflow(webDriver);
            CatalogItem            item       = uxWorkFlow.GetCatalogItem(environment, itemType, type, status, region, profileName, identityName);

            webDriver = webDriver.SwitchBrowser(BrowserName.InternetExplorer);
            webDriver.Navigate().GoToUrl(Convert.ToString(ConfigurationManager.AppSettings["BasePOURL"]));
            B2BQaToolsPage = new B2BQaToolsPage(webDriver);

            B2BQaToolsPage.PasteTargetUrl((environment == B2BEnvironment.Production) ? Convert.ToString(ConfigurationManager.AppSettings["QAToolsTargetUrlProd"])
                : Convert.ToString(ConfigurationManager.AppSettings["QAToolsTargetUrlPrev"]));

            string supplierPartIdExt = string.Empty;

            supplierPartIdExt = (crtStatus == CRTStatus.OFF) ? item.PartId : item.ManufacturerPartNumber;
            var unitPrice = Convert.ToString(item.UnitPrice);
            var file      = PoXmlGenerator.GeneratePoCxmll(fileName, uniquePoRefNum, profileName, identityName, supplierPartIdExt, unitPrice, quantity);

            B2BQaToolsPage.PasteInputXml(file);
            webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMinutes(2));
            B2BQaToolsPage.ClickSubmitMessage();
            if (B2BQaToolsPage.GetSubmissionResult().Equals("XML Response received from server Code: 200. Message: PO = " + uniquePoRefNum))
            {
                webDriver.Quit();
                Console.WriteLine("Success: PO Number: " + uniquePoRefNum);
                return(uniquePoRefNum);
            }
            else
            {
                Console.WriteLine("Error while posting PO: " + B2BQaToolsPage.GetSubmissionResult());
                Console.WriteLine("Fail: PO Number: " + uniquePoRefNum);
                throw new Exception("Error while posting PO: " + uniquePoRefNum);
            }
        }
Exemplo n.º 3
0
        /* How to create 'E-Quote' or 'OrQuote'
         * Call CompleteEQuoteGeneration() with 5 arguments -
         * i) quoteType(equote/OrQuote)     <-- Note pass only "equote" for E-Quote and "OrQuote" for OR-Quote
         * ii) environment - "Preview" or "Prod"
         * iii) profileId - In String
         * iv) name - any name      <- will be used in equote
         * v) email - any email     <- will be used in equote
         */

        public bool CompleteQuoteGeneration(
            string profileId,
            string name,
            string email,
            RunEnvironment environment,
            Workflow workflow,
            PoXmlFormat format,
            string deploymentMode,
            string orderIdBase,
            string poTargetUrl,
            string configFilterVal,
            string testEnvironment,
            List <QuoteDetail> listOfQuoteDetail,
            out string poNumber,
            out List <QuoteDetail> quoteDetail)
        {
            string responseCode = "0";
            var    parentWindow = webDriver.CurrentWindowHandle;

            B2BHomePage.SelectEnvironment(environment.ToString());

            // Quote Details are not available - Quote creation steps will be Executed else directly executes PO submission
            if (listOfQuoteDetail == null || !listOfQuoteDetail.Any() ||
                string.IsNullOrEmpty(listOfQuoteDetail.FirstOrDefault().SupplierPartId))
            {
                B2BHomePage.ClickQaTools3();
                webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                webDriver.SwitchTo().Window(webDriver.WindowHandles.Last());
                var QaToolsWindow = webDriver.CurrentWindowHandle;
                B2BQaToolsPage.SelectLocationAndEnvironment(environment.ToString(), testEnvironment);
                B2BQaToolsPage.ClickPunchoutCreate();
                B2BQaToolsPage.ClickCxml();
                B2BQaToolsPage.ClickCxmlMainCreate();
                B2BQaToolsPage.IdentityForProfileCorrelator(profileId);
                B2BQaToolsPage.IdentityForUserId(profileId);
                B2BQaToolsPage.ClickApplyParameter();
                B2BQaToolsPage.ClickSubmitMessage();
                responseCode = B2BQaToolsPage.GetSubmissionResult();
                Console.WriteLine("Response Code is :- " + responseCode);

                if (responseCode.Contains("200"))
                {
                    string temp = B2BQaToolsPage.GetStoreLinkText();
                    Console.WriteLine("Link value is " + temp);
                    B2BQaToolsPage.ClickStoreLink();
                    webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                    webDriver.Close();
                    string newwindow = webDriver.WindowHandles.LastOrDefault();
                    webDriver.SwitchTo().Window(newwindow);
                    //webDriver.SwitchTo().Window(webDriver.WindowHandles.Last());
                    var premierWindow = webDriver.CurrentWindowHandle;

                    webDriver.Manage().Window.Maximize();
                    B2BPremierDashboardPage.WaitForTitle();
                    B2BPremierDashboardPage.OpenShop();
                    B2BPremierDashboardPage.ClickStandardConfiguration();
                    if (workflow == Workflow.Asn)
                    {
                        B2BStandardConfigurationPage.SelectSpecificConfiguration(configFilterVal, listOfQuoteDetail.FirstOrDefault().ItemDescription);
                    }
                    else
                    {
                        B2BStandardConfigurationPage.SelectFirstConfiguration();
                    }
                    webDriver.WaitForPageLoad(new TimeSpan(0, 0, 20));
                    B2BStandardConfigurationPage.ClickAddSelectedToCartButton();
                    Console.WriteLine("Shoping Cart Page Title is :- " + ShopingCartPage.ReturnShopingCartTitle());
                    ShopingCartPage.ClickSaveQuote(listOfQuoteDetail.FirstOrDefault().QuoteType);

                    // Starting EQuote Generation
                    if (listOfQuoteDetail.FirstOrDefault().QuoteType == QuoteType.EQuote)
                    {
                        Console.WriteLine("EQuote Page Details Page Title is :-" + eQuoteDetailsPage.ReturnTitle());
                        eQuoteDetailsPage.EquoteNameSetting(name);
                        eQuoteDetailsPage.SavedBySetting(email);
                        eQuoteDetailsPage.ClickContinueButton();
                        webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                        eQuoteSummaryPage.ClickContinueButton();
                        webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                        finalEquoteSummaryPage.ClickSaveButton();
                        webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                        listOfQuoteDetail.FirstOrDefault().SupplierPartId = "EQ:" + eQuoteGenerationPage.ReturnNumber();
                        listOfQuoteDetail.FirstOrDefault().Price          = eQuoteGenerationPage.ReturnPrice().Replace("$", "");
                        Console.WriteLine("Your Equote Number is :- " + listOfQuoteDetail.FirstOrDefault().SupplierPartId);
                        Console.WriteLine("Price is :- " + listOfQuoteDetail.FirstOrDefault().Price);
                        webDriver.SwitchTo().Window(parentWindow);
                    }

                    // Starting OrQuote Generation
                    else if (listOfQuoteDetail.FirstOrDefault().QuoteType == QuoteType.OrQuote)
                    {
                        B2BSecureCheckoutPage.EnterContactAndBillingInfo();
                        webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                        listOfQuoteDetail.FirstOrDefault().Price = B2BTermsOfSalesPage.FindPrice().Replace("$", "");
                        B2BTermsOfSalesPage.ClickSubmitButton();
                        webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                        Console.WriteLine("Price is :- " + listOfQuoteDetail.FirstOrDefault().Price);
                        listOfQuoteDetail.FirstOrDefault().SupplierPartId = B2BOrQuoteGenerationPage.FindOrQuote();
                        webDriver.SwitchTo().Window(parentWindow);
                    }

                    else
                    {
                        Console.WriteLine("Quote Type is not Specified");
                        poNumber    = string.Empty;
                        quoteDetail = listOfQuoteDetail;
                        return(false);
                    }
                }
            }

            // Generates PO Template
            var    orderId = orderIdBase + DateTime.Today.ToString("yyMMdd") + DateTime.Now.ToString("HHmmss");
            string poXml;

            if (workflow == Workflow.Eudc)
            {
                poXml = PoXmlGenerator.GeneratePoCxmlCblForEudc(
                    format,
                    profileId,
                    deploymentMode,
                    orderId,
                    listOfQuoteDetail.FirstOrDefault().Price,
                    listOfQuoteDetail.FirstOrDefault().SupplierPartId,
                    listOfQuoteDetail.FirstOrDefault().CrtId);
            }
            else
            {
                poXml = PoXmlGenerator.GeneratePoCblForAsn(format, orderId, profileId, listOfQuoteDetail);
            }

            // Submits PO
            B2BHomePage.ClickQaTools3();
            if (!poOperations.SubmitXmlForPoCreation(poXml, environment.ToString(), poTargetUrl, testEnvironment, out poNumber))
            {
                quoteDetail = listOfQuoteDetail;
                return(false);
            }

            // verifies all validation after submiting PO
            webDriver.Close();
            webDriver.SwitchTo().Window(parentWindow);
            webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
            quoteDetail = listOfQuoteDetail;
            return(true);
        }