Example #1
0
        public Product GetProductDetails(string url)
        {
            var product = new Product();

            SetUrl(url);
            Thread.Sleep(2000);
            try
            {
                product.url = url;

                var container = wait.Until(ExpectedConditions.ElementExists(By.ClassName("show-for-large-up")));

                var photos = chrome.FindElements(By.ClassName("photo"));
                var thumbs = chrome.FindElements(By.ClassName("thumb"));

                for (int i = 0; i < photos.Count; i++)
                {
                    product.mainImageUrls += photos[i].GetAttribute("href");
                    if (i < photos.Count - 1)
                        product.mainImageUrls += "|";
                }

                for (int i = 0; i < thumbs.Count; i++)
                {
                    product.thumbnailUrls += thumbs[i].FindElement(By.TagName("img")).GetAttribute("src");
                    if (i < thumbs.Count - 1)
                        product.thumbnailUrls += "|";
                }

                var headings = chrome.FindElements(By.ClassName("headings"));

                foreach (var heading in headings)
                {
                    var contents = heading.FindElements(By.ClassName("content"));
                    if (contents == null || contents.Count == 0)
                    {
                        product.overview += heading.Text.ReplaceReturnAndComma();
                    }
                    else
                    {
                        product.ingredient = contents[0].GetAttribute("textContent").ReplaceReturnAndComma();
                        product.application = contents[1].GetAttribute("textContent").ReplaceReturnAndComma();
                        product.ingredientDetail = contents[2].GetAttribute("textContent").ReplaceReturnAndComma();
                    }
                }

                product.name = chrome.FindElement(By.ClassName("page-title")).Text.ReplaceReturnAndComma();

            }
            catch { }
            return product;
        }
Example #2
0
        public Product GetProductDetails(string url)
        {
            var product = new Product();

            SetUrl(url);
            Thread.Sleep(3000);
            try
            {
                product.url = url;

                var container = wait.Until(ExpectedConditions.ElementExists(By.ClassName("product-details")));

                product.thumbnailUrls = container.FindElement(By.ClassName("product-img-thumbs")).FindElement(By.ClassName("product-image")).GetAttribute("src");
                product.mainImageUrls = container.FindElement(By.ClassName("product-img-main")).FindElement(By.ClassName("ish-product-image-zoomable")).GetAttribute("src");
                var infoContainer = container.FindElement(By.ClassName("product-info"));
                product.name = infoContainer.FindElement(By.ClassName("flush-top")).Text;
                product.overview = infoContainer.FindElement(By.Id("overview")).Text.ReplaceReturnAndComma();
                product.ingredient = infoContainer.FindElement(By.Id("ingredient")).GetAttribute("textContent").ReplaceReturnAndComma();
            }
            catch { }
            return product;
        }
Example #3
0
        public Product GetProductDetails(string url)
        {
            var product = new Product();
            SetUrl(url);
            Thread.Sleep(1000);
            product.url = url;
            try
            {
                var imageContainer = wait.Until(ExpectedConditions.ElementExists(By.Id("imageViewerInner")));

                var mainImages = imageContainer.FindElements(By.TagName("Img"));
                var thumbNails = chrome.FindElement(By.ClassName("thumb-window")).FindElements(By.TagName("Img"));

                for (int i = 0; i < mainImages.Count; i++)
                {
                    product.mainImageUrls += mainImages[i].GetAttribute("src");

                    if (i < mainImages.Count - 1)
                        product.mainImageUrls += "|";
                }

                for (int i = 0; i < thumbNails.Count; i++)
                {
                    if (!thumbNails[i].GetAttribute("class").Contains("overlay"))
                    {
                        product.thumbnailUrls += thumbNails[i].GetAttribute("src");

                        if (i < mainImages.Count - 1)
                            product.mainImageUrls += "|";
                    }
                }

                var pDetail = chrome.FindElement(By.ClassName("product-header"));

                product.brand = pDetail.FindElement(By.TagName("h4")).Text;
                product.name = pDetail.FindElement(By.TagName("h3")).Text;
                product.price = chrome.FindElementsByClassName("price").First().Text;

                var omega = chrome.FindElementsByClassName("omega");
                var ps = omega[0].FindElements(By.TagName("p"));
                product.overview = ps[0].Text.ReplaceReturnAndComma(); //description
                product.feature = ps[1].Text.ReplaceReturnAndComma();
                product.benefits = ps[2].Text.ReplaceReturnAndComma();

                var li = omega[2].FindElements(By.TagName("li"));

                product.quantity = li[2].Text;
                product.size = li[4].Text;
                var li2 = omega[3].FindElements(By.TagName("li"));
                product.sku = li2[2].Text;
                product.barcode = li2[4].Text;

                var a = chrome.FindElementByClassName("product-attributes-list").FindElements(By.TagName("a"));
                product.attribute = "";
                for (int i = 0; i < a.Count; i++)
                {
                    product.attribute += a[i].Text.ReplaceReturnAndComma();

                    if (i < a.Count - 1)
                        product.attribute += "|";
                }

                product.ingredient = chrome.FindElementByClassName("product-ingredients-wrapper ").FindElement(By.TagName("p")).Text.ReplaceReturnAndComma();

            }
            catch
            { }

            return product;
        }