private void AddImageToBoard(string userUrl)
        {
            Сhrome.OpenUrlNewTab(userUrl);
            IWebElement Element_photo = Сhrome.FindWebElement(By.XPath("//div[@class = 'e2e-Work']/div/div[1]/div[1]/div/div/div[2]/a"));

            if (Element_photo == null)
            {
                Cons.WriteLine($"AddImageToBoard. v2 {userUrl}");
                Сhrome.CloseAndReturnTab();
                return;
            }

            string url_photo = Element_photo.GetAttribute("href");

            Сhrome.OpenUrl(url_photo);

            Thread.Sleep(1000);
            if (!Сhrome.ClickButtonXPath("//div[. = 'Сохранить']"))
            {
                Cons.WriteLine($"Error open board.");
                Сhrome.CloseAndReturnTab();
                return;
            }

            Thread.Sleep(500);
            if (Сhrome.FindWebElement(By.XPath("//*[contains(text(), 'Новая доска настроени')]")) == null)
            {
                if (!Сhrome.ClickButtonXPath("//div[. = 'Сохранить']"))
                {
                    Cons.WriteLine($"Error check open board.");
                    Сhrome.CloseAndReturnTab();
                    return;
                }
            }

            Thread.Sleep(200);
            if (!Сhrome.ClickButtonXPath($"//li[. ='{GetRandomNameBoard()}']"))
            {
                Cons.WriteLine($"Error select board.");
            }

            Thread.Sleep(600);
            if (!Сhrome.ClickButtonXPath("//button[. ='Сохранить']"))
            {
                Cons.WriteLine($"Error save image to board.");
            }

            Thread.Sleep(3000);
            Сhrome.CloseAndReturnTab();
        }
Beispiel #2
0
        internal override void Start(int limit)
        {
            while (true)
            {
                if (!OpenRandomFollowerPage())
                {
                    return;
                }

                for (int i = 3; i < 3000; i++)
                {
                    string xpathNextUser = UserXpath + "/li[" + i + "]";

                    if (like_counter >= limit)
                    {
                        return;
                    }

                    if (IsBlock())
                    {
                        return;
                    }

                    if (!Сhrome.Scroll(xpathNextUser))
                    {
                        break;
                    }
                    if (CheckUser(xpathNextUser, out string userUrl, out _, out _, out _))
                    {
                        if (userUrl == null)
                        {
                            continue;
                        }

                        LikePhoto(userUrl);
                        like_counter++;
                        Cons.WriteLine($"Like!#{like_counter}");
                        db.AddUser(userUrl, 0, 0, 0);
                    }
                }
                Cons.WriteLine("End following list");
            }


            void LikePhoto(string userUrl)
            {
                if (userUrl == null)
                {
                    return;
                }


                Сhrome.OpenUrlNewTab(userUrl);

                IWebElement Element_photo = Сhrome.FindWebElement(By.XPath(@"//*[@id='site-content']/div/main/div[2]/div[2]/div/div/div/div/div[1]/div[1]/div/div/div[2]/a"));

                if (Element_photo == null)
                {
                    Thread.Sleep(3000);
                    Сhrome.CloseAndReturnTab();
                    return;
                }

                Сhrome.OpenUrl(Element_photo.GetAttribute("href"));
                Thread.Sleep(300);

                if (!Сhrome.ClickButtonXPath(@"//div[.='Оценить']"))
                {
                    Cons.WriteLine($"Error like!");
                }

                Thread.Sleep(1000);
                Сhrome.CloseAndReturnTab();
            }
        }