Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting....");
            ChromeOptions options = new ChromeOptions();

            options.AddArguments("load-extension=C:/Users/Ben/AppData/Local/Google/Chrome/User Data/Default/Extensions/gkbhgdhhefdphpikedbinecandoigdel/3.5.7_0");
            IWebDriver driver = new ChromeDriver(options);

            //driver.Manage().Window.Maximize();

            WebPinner.TailwindLogin(driver, args);

            WebPinner.getS6Products(driver);

            Console.ReadLine();

            //driver.Quit();
        }
Beispiel #2
0
        static private Boolean getS6Products(IWebDriver driver)
        {
            string home = "https://society6.com/samanndesigns/duvet-covers?sort=new";

            driver.Navigate().GoToUrl(home);

            IList <IWebElement> links = new List <IWebElement>();

            try {
                links = driver.FindElements(By.ClassName("title_product_1YKi0"));
            }
            catch (NoSuchElementException e) {
                IWebElement advert = driver.FindElement(By.ClassName("bx-close-link"));
                advert.Click();
            }
            catch (StaleElementReferenceException e) {
                IWebElement advert = driver.FindElement(By.ClassName("bx-close-link"));
                advert.Click();
            }
            finally {
                links = driver.FindElements(By.ClassName("title_product_1YKi0"));
            }

            Console.WriteLine("Number of Links: " + links.Count());

            int           count        = 0;
            string        url          = "";
            List <string> productLinks = new List <string>();

            foreach (IWebElement item in links)
            {
                try {
                    url = item.GetAttribute("href");
                }
                catch (NoSuchElementException e) {
                    IWebElement advert = driver.FindElement(By.ClassName("bx-close-link"));
                    advert.Click();
                }
                catch (StaleElementReferenceException e) {
                    IWebElement advert = driver.FindElement(By.ClassName("bx-close-link"));
                    advert.Click();
                }
                finally {
                    url = item.GetAttribute("href");
                }

                productLinks.Add(url);
                Console.WriteLine(url);
            }

            Actions clicker = new Actions(driver);

            foreach (string prodLink in productLinks)
            {
                Console.WriteLine("going to product");
                driver.Navigate().GoToUrl(prodLink);
                Thread.Sleep(2000);

                WebPinner.ClickScheduleButton(driver);

                Thread.Sleep(2500);

                Console.WriteLine("going home");
                driver.Navigate().GoToUrl(home);
                Thread.Sleep(2500);

                if (++count > 5)
                {
                    break;
                }
            }

            return(true);
        }