using DemoBlazeAutomation.POM; using OpenQA.Selenium; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace DemoBlazeAutomation.POM { public class ProductDetailPage : BasePage { public ProductDetailPage(IWebDriver driver): base(driver) { } private List <decimal> listaDePrecios = new List<decimal>(); IWebElement BtnAddToCart => GetElementWhenIsClickeable(SelectorType.LinkText, "Add to cart"); IWebElement Cart => GetElementWhenIsClickeable(SelectorType.Id, "cartur"); //IWebElement PriceProduct => GetElementWhenIsClickeable(SelectorType.TagName, "h3"); IWebElement PriceProduct => GetElementWhenExists(By.TagName("h3")); public void AddToCart() { listaDePrecios.Add(Price()); ClickElement(BtnAddToCart); DismissAlert(); GoToSection("Home"); } //opcional public void GoToCart() { ClickElement(Cart); } public void GoToSection(string sectionName) { ClickElement(GetElementWhenIsClickeable(SelectorType.PartialLinkText, sectionName)); } public int TotalProductAdded() => listaDePrecios.Count(); public decimal TotalPriceProduct() => listaDePrecios.Sum(); public decimal Price() { var price = PriceProduct.Text; var priceCleaned = decimal.Parse(price.Replace("$", "").Trim('$', '*', ' ', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 's', 't', 'a', 'x')); return priceCleaned; } } }