Beispiel #1
0
        public void CreacionProducto(String productoExistente, String uso, String unidadVenta, String metros, String modalidadContratacion, String nrc, String duracionContrato, String PrecioMensual, String Infraestuctura)
        {
            try
            {
                Utils.SearchWebElement("Oferta.buttonAgregarProducto").Click();

                // Seleccionar Producto existente del desplegable
                wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath(Utils.GetIdentifier("Producto.inputProductoExistente"))));
                Utils.SearchWebElement("Producto.inputProductoExistente").Click();
                Utils.SearchWebElement("Producto.inputProductoExistente").SendKeys(productoExistente);
                wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath(Utils.GetIdentifier("Oferta.buttonBuscarProductoExistente"))));
                string id = driver.FindElement(Utils.getByElement("Oferta.buttonBuscarProductoExistente")).GetAttribute("id");

                IJavaScriptExecutor js = driver as IJavaScriptExecutor;
                js.ExecuteScript("document.getElementById('" + id + "').click()");

                Utils.SearchWebElement("Oferta.buttonBuscarProductoExistente").Click();
                wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath("//div[contains(@data-id,'LookupResultsDropdown')]/span[contains(., '" + productoExistente + "')]")));
                driver.FindElement(By.XPath("//div[contains(@data-id,'LookupResultsDropdown')]/span[contains(., '" + productoExistente + "')]")).Click();
                Thread.Sleep(2000);
                driver.FindElement(By.XPath("//h1[text()='Creación rápida: Producto de oferta']")).Click();

                // Seleccionar infraestructura

                /*wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(Utils.getByElement("Oferta.Infastructura")));
                 * if (!Infraestuctura.Equals(""))
                 * {
                 *  Utils.SearchWebElement("Oferta.Infastructura").Click();
                 *  Thread.Sleep(1000);
                 *
                 *  Utils.SearchWebElement("Oferta.Infastructura").SendKeys(Infraestuctura);
                 *  Thread.Sleep(2000);
                 *  Utils.SearchWebElement("Oferta.Infastructura").SendKeys(Keys.Control + "a");
                 *  Utils.SearchWebElement("Oferta.Infastructura").SendKeys(Keys.Delete);
                 *  Utils.SearchWebElement("Oferta.Infastructura").SendKeys(Infraestuctura);
                 *  Thread.Sleep(2000);
                 *  driver.FindElement(By.XPath("//span[contains(., '" + Infraestuctura + "')]")).Click();
                 *  Thread.Sleep(2000);
                 * }*/

                // Seleccionar Uso(Línea de negocio)
                if (!uso.Equals(""))
                {
                    SelectElement drop = new SelectElement(Utils.SearchWebElement("Producto.SelectUsoLineaNegocio"));
                    drop.SelectByText(uso);
                }
            }
            catch (Exception e)
            {
                CommonActions.CapturadorExcepcion(e, "AddProducto.png", "No se añaden correctamente los datos del Producto: " + productoExistente + ", " + uso + ", " + unidadVenta);
                throw e;
            }

            if (!unidadVenta.Equals("") && utils.EncontrarElemento(By.XPath(Utils.GetIdentifier("Producto.inputUnidaddeVenta"))))
            {
                // Seleccionar Producto existente del desplegable si esta vacio
                if (utils.EncontrarElemento(By.XPath("//input[contains(@id,'Dropdown_uomid')]")))
                {
                    try
                    {
                        Utils.SearchWebElement("Producto.inputUnidaddeVenta").Click();
                        Thread.Sleep(1000);
                        Utils.SearchWebElement("Producto.inputUnidaddeVenta").SendKeys(unidadVenta);
                        Thread.Sleep(2000);
                        Utils.SearchWebElement("Producto.inputUnidaddeVenta").SendKeys(Keys.Control + "a");
                        Utils.SearchWebElement("Producto.inputUnidaddeVenta").SendKeys(Keys.Delete);
                        Utils.SearchWebElement("Producto.inputUnidaddeVenta").SendKeys(unidadVenta);
                        Thread.Sleep(2000);
                        driver.FindElement(By.XPath("//span[contains(text(), '" + unidadVenta + "')]")).Click();
                        Thread.Sleep(2000);
                        driver.FindElement(By.XPath("//h1[text()='Creación rápida: Producto de oferta']")).Click();
                    }
                    catch (Exception e)
                    {
                        CommonActions.CapturadorExcepcion(e, "AddProducto.png", "No se añaden correctamente los datos del Producto: " + productoExistente + ", " + uso + ", " + unidadVenta);
                        throw e;
                    }
                }
            }

            // Introduccir metros
            if (!metros.Equals(""))
            {
                Utils.SearchWebElement("Producto.inputMetros").Click();
                Thread.Sleep(1000);

                Utils.SearchWebElement("Producto.inputMetros").SendKeys(metros);
                Thread.Sleep(1000);
                Utils.SearchWebElement("Producto.inputMetros").SendKeys(Keys.Control + "a");
                Utils.SearchWebElement("Producto.inputMetros").SendKeys(Keys.Delete);
                Utils.SearchWebElement("Producto.inputMetros").SendKeys(metros);
                Thread.Sleep(1000);
                driver.FindElement(By.XPath("//h1[text()='Creación rápida: Producto de oferta']")).Click();
            }

            // Introduccir Modalidad de Contratacion
            if (!modalidadContratacion.Equals(""))
            {
                SelectElement drop = new SelectElement(Utils.SearchWebElement("Producto.SelectModalidadContratacion"));
                drop.SelectByText(modalidadContratacion);
            }

            // Introduccir NRC
            if (!nrc.Equals(""))
            {
                Utils.SearchWebElement("Producto.selectNRC").Click();
                Thread.Sleep(1000);

                Utils.SearchWebElement("Producto.selectNRC").SendKeys(nrc);
                Thread.Sleep(1000);
                Utils.SearchWebElement("Producto.selectNRC").SendKeys(Keys.Control + "a");
                Utils.SearchWebElement("Producto.selectNRC").SendKeys(Keys.Delete);
                Utils.SearchWebElement("Producto.selectNRC").SendKeys(nrc);
                Thread.Sleep(1000);
                driver.FindElement(By.XPath("//h1[text()='Creación rápida: Producto de oferta']")).Click();
            }


            // Introduccir Duración de Contrato
            if (!duracionContrato.Equals(""))
            {
                Utils.SearchWebElement("Producto.inputDuracionContrato").Click();
                Thread.Sleep(1000);

                Utils.SearchWebElement("Producto.inputDuracionContrato").SendKeys(duracionContrato);
                Thread.Sleep(1000);
                Utils.SearchWebElement("Producto.inputDuracionContrato").SendKeys(Keys.Control + "a");
                Utils.SearchWebElement("Producto.inputDuracionContrato").SendKeys(Keys.Delete);
                Utils.SearchWebElement("Producto.inputDuracionContrato").SendKeys(duracionContrato);
                Thread.Sleep(3000);
                driver.FindElement(By.XPath("//h1[text()='Creación rápida: Producto de oferta']")).Click();
            }

            // Introduccir precio mensual
            if (!PrecioMensual.Equals(""))
            {
                Utils.SearchWebElement("Producto.inputPrecioMensual2").Click();
                Thread.Sleep(2000);

                Utils.SearchWebElement("Producto.inputPrecioMensual2").SendKeys(PrecioMensual);
                Thread.Sleep(1000);
                Utils.SearchWebElement("Producto.inputPrecioMensual2").SendKeys(Keys.Control + "a");
                Utils.SearchWebElement("Producto.inputPrecioMensual2").SendKeys(Keys.Delete);
                Utils.SearchWebElement("Producto.inputPrecioMensual2").SendKeys(PrecioMensual);
                Thread.Sleep(1000);
                driver.FindElement(By.XPath("//h1[text()='Creación rápida: Producto de oferta']")).Click();
            }

            try
            {
                // Guardar y Cerrar Producto actual
                Utils.SearchWebElement("Producto.GuardarYCerrar_producto").Click();
                Thread.Sleep(24000);
                Utils.SearchWebElement("Oferta.saveOferta").Click();
                TestContext.WriteLine("Producto guardado correctamente: " + productoExistente + ", " + uso + ", " + unidadVenta + ", " + metros + ", " + nrc + ", " + modalidadContratacion);
            }
            catch (Exception e)
            {
                CommonActions.CapturadorExcepcion(e, "GuardarProducto.png", "El producto no fue creado: " + productoExistente + ", " + uso + ", " + unidadVenta + ", " + metros + ", " + nrc + ", " + modalidadContratacion);
                throw e;
            }
        }
Beispiel #2
0
        //Metodo para agregar producto heredado
        public void HeredarProducto(String productoHeredado, String precioMensual, String duracionContrato, String nrc, String metros, String precioMetroAnual, String Venta)
        {
            // Click en "+ Agregar producto"
            Utils.SearchWebElement("Producto.buttonAgregarProducto").Click();
            Thread.Sleep(4000);

            try
            {
                if (!productoHeredado.Equals(""))
                {
                    wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath(Utils.GetIdentifier("Producto.inputServicioHeredado"))));
                    Utils.SearchWebElement("Producto.inputServicioHeredado").Click();
                    Utils.SearchWebElement("Producto.inputServicioHeredado").SendKeys(Keys.Control + "a");
                    Utils.SearchWebElement("Producto.inputServicioHeredado").SendKeys(Keys.Delete);

                    Utils.SearchWebElement("Producto.inputServicioHeredado").SendKeys(productoHeredado);
                    driver.FindElement(By.XPath("//span[contains(text(), '" + productoHeredado + "')]")).Click();
                    Thread.Sleep(3000);
                    wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath("//input[@aria-label='Cód. admin. servicio heredado']")));
                    driver.FindElement(By.XPath("//input[@aria-label='Cód. admin. servicio heredado']")).SendKeys(Keys.PageDown);
                    Thread.Sleep(6000);
                }

                if (!precioMensual.Equals(""))
                {
                    Utils.SearchWebElement("Producto.selectPrecioMensual").Click();
                    Utils.SearchWebElement("Producto.selectPrecioMensual").SendKeys(Keys.Control + "a");
                    Utils.SearchWebElement("Producto.selectPrecioMensual").SendKeys(Keys.Delete);

                    Utils.SearchWebElement("Producto.selectPrecioMensual").SendKeys(precioMensual);
                }

                if (!metros.Equals(""))
                {
                    Utils.SearchWebElement("Producto.inputMetros").Click();
                    Utils.SearchWebElement("Producto.inputMetros").SendKeys(Keys.Control + "a");
                    Utils.SearchWebElement("Producto.inputMetros").SendKeys(Keys.Delete);
                    Utils.SearchWebElement("Producto.inputMetros").SendKeys(metros);
                }

                if (!precioMetroAnual.Equals(""))
                {
                    Utils.SearchWebElement("Producto.inputPrecioMetroAnual").Click();
                    Utils.SearchWebElement("Producto.inputPrecioMetroAnual").SendKeys(Keys.Control + "a");
                    Utils.SearchWebElement("Producto.inputPrecioMetroAnual").SendKeys(Keys.Delete);

                    Utils.SearchWebElement("Producto.inputPrecioMetroAnual").SendKeys(precioMetroAnual);
                }



                if (!duracionContrato.Equals(""))
                {
                    Utils.SearchWebElement("Producto.selectDuracionContrato").Click();
                    Utils.SearchWebElement("Producto.selectDuracionContrato").SendKeys(Keys.Control + "a");
                    Utils.SearchWebElement("Producto.selectDuracionContrato").SendKeys(Keys.Delete);

                    Utils.SearchWebElement("Producto.selectDuracionContrato").SendKeys(duracionContrato);
                }

                if (!nrc.Equals(""))
                {
                    Utils.SearchWebElement("Producto.selectNRC").Click();
                    Utils.SearchWebElement("Producto.selectNRC").SendKeys(Keys.Control + "a");
                    Utils.SearchWebElement("Producto.selectNRC").SendKeys(Keys.Delete);

                    Utils.SearchWebElement("Producto.selectNRC").SendKeys(nrc);
                    Thread.Sleep(3000);
                }

                if (!Venta.Equals(""))
                {
                    Utils.SearchWebElement("Producto.inputUnidaddeVenta").Click();
                    Thread.Sleep(1000);

                    Utils.SearchWebElement("Producto.inputUnidaddeVenta").SendKeys(Venta);
                    Thread.Sleep(2000);
                    Utils.SearchWebElement("Producto.inputUnidaddeVenta").SendKeys(Keys.Control + "a");
                    Thread.Sleep(2000);
                    Utils.SearchWebElement("Producto.inputUnidaddeVenta").SendKeys(Keys.Delete);
                    Thread.Sleep(2000);
                    Utils.SearchWebElement("Producto.inputUnidaddeVenta").SendKeys(Venta);
                    Thread.Sleep(2000);
                    driver.FindElement(By.XPath("//span[contains(text(), '" + Venta + "')]")).Click();
                    Thread.Sleep(2000);
                }


                Utils.SearchWebElement("Producto.GuardarYCerrar_producto").Click();
                Thread.Sleep(40000);
                TestContext.WriteLine("El tipo de producto heredado con sus parametros se guarda correctamente");
            }

            catch (Exception e)
            {
                CommonActions.CapturadorExcepcion(e, "Producto heredado.png", "***productoHeredado, precioMensual, duracionContrato, nrc, metros, precioMetroAnual no se guarda correctamente");
                throw e;
            }
        }