コード例 #1
0
ファイル: Bot.cs プロジェクト: user-13B1/BehanceSubscriber
        internal bool Autorize(string v1, string v2)
        {
            int timeSleep = 2000;

#if DEBUG
            timeSleep /= 2;
#endif
            Cons.WriteLine($"{Name}: authorization.");
            Сhrome.OpenUrl(@"https://www.behance.net/search");

            if (Сhrome.FindWebElement(By.XPath("//a[@aria-label ='Создать проект']")) != null)
            {
                Cons.WriteLine($"{Name}: authorization - ok.");
                return(true);
            }

            //---Enter---
            IWebElement Element = Сhrome.FindWebElement(By.XPath("//li/div/button[contains(.,'Вход')]"));
            Element.Click();

            Thread.Sleep(timeSleep);
            Сhrome.SendKeysXPath(".//input[@id='EmailPage-EmailField']", v1);
            Thread.Sleep(timeSleep);
            Сhrome.ClickButtonXPath(".//*[@id='EmailForm']/section[2]/div[2]/button");
            Thread.Sleep(timeSleep);
            Сhrome.SendKeysXPath(".//input[@id='PasswordPage-PasswordField']", v2);
            Thread.Sleep(timeSleep);
            Сhrome.ClickButtonXPath(".//*[@id='PasswordForm']/section[2]/div[2]/button");
            Thread.Sleep(TimeSpan.FromSeconds(7));

            Сhrome.OpenUrl(@"https://www.behance.net");
            if (Сhrome.FindWebElement(By.XPath("//*[contains(text(), 'Создать проект')]")) == null)
            {
                Cons.WriteLine($"{Name}: Error autorize.");
                return(false);
            }
            Cons.WriteLine($"{Name}: Authorized.");
            return(true);
        }