Beispiel #1
0
        public void AddPersonRecordForMassEmail()
        {
            IWebElement elcrmLink, elUserLink;
            string      tmpStr, tStr;
            int         i, j;
            PersonTest  person = new PersonTest();

            //    *[@id='MassUpdate']/table/tbody/tr[4]/td[3]/b/a
            //    *[@id='MassUpdate']/table/tbody/tr[4]/td[5]
            //    *[@id='MassUpdate']/table/tbody/tr[4]/td[8]
            //     .//*[@id='listViewNextButton_bottom']
            for (i = 0; i < 20; i++)
            {
                //имя пользователя в результатах поиска сrmLink
                tmpStr = "//*[@id='MassUpdate']/table/tbody/tr[" + (i + 3).ToString() + "]/td[3]/b/a";
                if (SeleniumHelper.IsElementPresent(By.XPath(tmpStr)))
                {
                    elcrmLink = SeleniumHelper.WaitForElement(By.XPath(tmpStr));
                    //linkedIn Link
                    tmpStr     = "//*[@id='MassUpdate']/table/tbody/tr[" + (i + 3).ToString() + "]/td[5]";
                    elUserLink = SeleniumHelper.WaitForElement(By.XPath(tmpStr));
                    // industryId
                    //tmpStr = "//*[@id='MassUpdate']/table/tbody/tr[" + (i + 3).ToString() + "]/td[8]";
                    //elIndustry = SeleniumHelper.WaitForElement(By.XPath(tmpStr));
                    //if (elIndustry.Text == "")
                    //    person.curIndustry = "0";
                    //else
                    //    person.curIndustry = elIndustry.Text;
                    //person.curIndustry = person.curIndustry.Replace(" ", "");
                    person.linkedinlink = elUserLink.Text;
                    person.crmLink      = elcrmLink.GetAttribute("href").ToString();
                    //      здесь была работа с сообщениями
                    // Заполнение поля Меssage
                    tStr = "data\\MassEmail\\" + Settings.BotSettings.CurrentUser + "\\Default.txt";
                    if (File.Exists(tStr))
                    {
                        tmpStr             = System.IO.File.ReadAllText(tStr);
                        person.messageText = tmpStr;
                        //person.isMessageSend = true;
                    }
                    else
                    {
                        continue;
                    }
                    //                 Добавление в список
                    personList.Add(person);
                    //                здесь был сontinue
                    return;
                }
                //                continue;
                //            }

                //            for (j = 0; j < Settings.BotSettings.listIndustry.Count(); j++)
                //            {
                //                tStr = Settings.BotSettings.listIndustry[j];
                //                if (tStr == person.curIndustry)
                //                {
                //                     Заполнение поля Меssage
                //                    tStr = "data\\MassEmail\\" + Settings.BotSettings.CurrentUser + "\\Message_" + person.curIndustry + ".txt";
                //                    if (File.Exists(tStr))
                //                    {
                //                        tmpStr = System.IO.File.ReadAllText(tStr);
                //                        person.messageText = tmpStr;
                //                        person.isMessageSend = true;
                //                    }
                //                    else
                //                        continue;
                //                     Добавление в список
                //                    personList.Add(person);
                //                    continue;
                //                }
                //            }
                //        }
                //        else
                //            break;
                //    }

                //    return;
            }
        }
Beispiel #2
0
        //public void AddPersonRecord()
        //{
        //    IWebElement elcrmLink, elUserLink, elIndustry;
        //    string tmpStr, tStr;
        //    int i, j;
        //    PersonIn person = new PersonIn();
        //    //*[@id='MassUpdate']/table/tbody/tr[4]/td[3]/b/a
        //    //*[@id='MassUpdate']/table/tbody/tr[4]/td[5]
        //    //*[@id='MassUpdate']/table/tbody/tr[4]/td[8]
        //    // .//*[@id='listViewNextButton_bottom']
        //    for (i = 0; i < 20; i++)
        //    {
        //        tmpStr = "//*[@id='MassUpdate']/table/tbody/tr[" + (i + 3).ToString() + "]/td[3]/b/a";
        //        if (SeleniumHelper.IsElementPresent(By.XPath(tmpStr)))
        //        {
        //            elcrmLink = SeleniumHelper.WaitForElement(By.XPath(tmpStr));
        //            tmpStr = "//*[@id='MassUpdate']/table/tbody/tr[" + (i + 3).ToString() + "]/td[5]";
        //            elUserLink = SeleniumHelper.WaitForElement(By.XPath(tmpStr));
        //            tmpStr = "//*[@id='MassUpdate']/table/tbody/tr[" + (i + 3).ToString() + "]/td[8]";
        //            elIndustry = SeleniumHelper.WaitForElement(By.XPath(tmpStr));
        //            if (elIndustry.Text == "")
        //                person.curIndustry = "0";
        //            else
        //                person.curIndustry = elIndustry.Text;
        //            person.curIndustry = person.curIndustry.Replace(" ", "");
        //            person.urlLink = elUserLink.Text;
        //            person.crmLink = elcrmLink.GetAttribute("href").ToString();
        //            person.messageText = "";
        //            person.isMessageSend = false;
        //            if (Settings.BotSettings.listIndustry[0] == "")
        //            {
        //                // Заполнение поля Меssage
        //                tStr = "data\\MassEmail\\" + Settings.BotSettings.CurrentUser + "\\Default.txt";
        //                if (File.Exists(tStr))
        //                {
        //                    tmpStr = System.IO.File.ReadAllText(tStr);
        //                    person.messageText = tmpStr;
        //                    person.isMessageSend = true;
        //                }
        //                else
        //                    continue;
        //                // Добавление в список
        //                personList.Add(person);
        //                continue;
        //            }

        //            for (j = 0; j < Settings.BotSettings.listIndustry.Count(); j++)
        //            {
        //                tStr = Settings.BotSettings.listIndustry[j];
        //                if (tStr == person.curIndustry)
        //                {
        //                    // Заполнение поля Меssage
        //                    tStr = "data\\MassEmail\\" + Settings.BotSettings.CurrentUser + "\\Message_" + person.curIndustry + ".txt";
        //                    if (File.Exists(tStr))
        //                    {
        //                        tmpStr = System.IO.File.ReadAllText(tStr);
        //                        person.messageText = tmpStr;
        //                        person.isMessageSend = true;
        //                    }
        //                    else
        //                        continue;
        //                    // Добавление в список
        //                    personList.Add(person);
        //                    continue;
        //                }
        //            }
        //        }
        //        else
        //            break;
        //    }

        //    return;
        //}

        //bool UnSetMessageSend(PersonTest person)
        //{
        //    IWebElement tstItem;
        //    int i = 0;

        //    browser.CrmNavigateTo(person.crmLink);
        //    System.Threading.Thread.Sleep(3000);
        //    try
        //    {
        //        tstItem = SeleniumHelper.WaitForElement(By.XPath("//*[@id='edit_button']"));
        //        tstItem.Click();
        //        System.Threading.Thread.Sleep(3000);

        //        tstItem = SeleniumHelper.WaitForElement(By.XPath("//*[@id='messagewassent_c']"));
        //        if (tstItem.Selected == true)
        //        {
        //            tstItem.Click();
        //        }
        //        //tstItem = SeleniumHelper.WaitForElement(By.XPath("//*[@id='edit_button']"));
        //        //tstItem.Click();
        //        tstItem = SeleniumHelper.WaitForElement(By.XPath("//*[@id='SAVE_HEADER']"));
        //        tstItem.Click();
        //        System.Threading.Thread.Sleep(3000);

        //    }
        //    catch (Exception ex)
        //    {
        //        return false;
        //    }
        //    return true;
        //}

        /*
         * Отсылка пользовательского сообщения Пользователю
         *
         */
        //rename

        // testing - public void SendMailUser()
        //public bool SendMailUser(PersonIn person)
        //{
        //    IWebElement elButton, elSubject, elMessage, elSendButton, elCancelButton, elUserName;
        //    string tmpStr, firstName, lastName, fullName;
        //    try
        //    {
        //        // Перейти на страницу пользователя
        //        browser.LinkedInNavigateTo(person.urlLink);
        //        //browser.LinkedInNavigateTo("https://mx.linkedin.com/in/nathan-green-17018a127");
        //        elButton = SeleniumHelper.WaitForElement(By.XPath("//*[@id='tc-actions-send-message']"));
        //        if (elButton.Text == "Send a message")
        //        {
        //            elUserName = SeleniumHelper.WaitForElement(By.XPath("//*[@id='name']/h1/span/span[1]"));
        //            fullName = elUserName.Text;

        //            elButton.Click();
        //            //System.Threading.Thread.Sleep(3000);
        //            elSubject = SeleniumHelper.WaitForElement(By.XPath("//*[@id='subject-msgForm']"));
        //            elMessage = SeleniumHelper.WaitForElement(By.XPath("//*[@id='body-msgForm']"));
        //            elCancelButton = SeleniumHelper.WaitForElement(By.XPath("//*[@class='dialog-close']"));
        //            elSendButton = SeleniumHelper.WaitForElement(By.XPath("//*[@id='compose-dialog-submit']"));
        //            // Установить заголовок сообщения
        //            elSubject.Clear();
        //            firstName = fullName.Split(' ')[0];
        //            lastName = fullName.Split(' ')[1];

        //            tmpStr = Settings.BotSettings.SubjectMessage;
        //            tmpStr = tmpStr.Replace("%FullName", fullName);
        //            tmpStr = tmpStr.Replace("%FirstName", firstName);
        //            tmpStr = tmpStr.Replace("%LastName", lastName);
        //            elSubject.SendKeys(tmpStr);

        //            tmpStr = person.messageText;
        //            tmpStr = tmpStr.Replace("%FullName", fullName);
        //            tmpStr = tmpStr.Replace("%FirstName", firstName);
        //            tmpStr = tmpStr.Replace("%LastName", lastName);
        //            elMessage.Clear();
        //            elMessage.SendKeys(tmpStr);
        //            //elCancelButton.Click();
        //            elSendButton.Click();
        //            //System.Threading.Thread.Sleep(5000);
        //        }
        //        else
        //        {
        //            return false;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        return false;
        //    }
        //    return true;
        //}

        /*
         * Отсылка пользовательского сообщения Пользователю test с voidом
         *
         */
        //public void SendMailUser()
        public bool SendMailUser(PersonTest person)
        {
            // elLogin, elPassword, signButton добавлены из-за блокировки сессии (Линкедин запрашивает авторизацию перед переходом на страницу юзера для отправки сообщения
            IWebElement elButton, elSubject, elMessage, elSendButton, elCancelButton, elUserName, elPassword, signButton, elLogin;
            string      tmpStr, firstName, lastName, fullName;

            try
            {
                //        // Перейти на страницу пользователя
                browser.LinkedInNavigateTo(person.linkedinlink);
                //browser.LinkedInNavigateTo("https://mx.linkedin.com/in/nathan-green-17018a127");
                // elButton = SeleniumHelper.WaitForElement(By.XPath("//*[@id='tc-actions-send-message']"));

                if (SeleniumHelper.IsElementPresent(By.Id("session_key-login")))
                {
                    SeleniumHelper.WaitForElement(By.Id("session_key-login"));
                    elLogin = browser.LinkedFindElement(By.Id("session_key-login"));
                    System.Threading.Thread.Sleep(5000);
                    elLogin.Clear();
                    elLogin.SendKeys(Settings.BotSettings.LoginLinkedIn);
                    SeleniumHelper.WaitForElement(By.XPath(".//*[@id='session_password-login']"));
                    elPassword = browser.LinkedFindElement(By.XPath(".//*[@id='session_password-login']"));
                    elPassword.SendKeys(Settings.BotSettings.PasswordLinkedIn);
                    System.Threading.Thread.Sleep(5000);
                    SeleniumHelper.WaitForElement(By.Id("btn-primary"));
                    signButton = browser.LinkedFindElement(By.Id("btn-primary"));
                    System.Threading.Thread.Sleep(5000);
                    signButton.Click();
                    //linkedView.LoginSessionBlocked();
                }
                else
                {
                    return(false);
                }
                elButton = SeleniumHelper.WaitForElement(By.XPath("//*[@id='tc-actions-send-message']"));
                if (elButton.Text == "Send a message")
                {
                    elUserName = SeleniumHelper.WaitForElement(By.XPath("//*[@id='name']/h1/span/span[1]"));
                    fullName   = elUserName.Text;

                    elButton.Click();
                    System.Threading.Thread.Sleep(3000);
                    elSubject      = SeleniumHelper.WaitForElement(By.XPath("//*[@id='subject-msgForm']"));
                    elMessage      = SeleniumHelper.WaitForElement(By.XPath("//*[@id='body-msgForm']"));
                    elCancelButton = SeleniumHelper.WaitForElement(By.XPath("//*[@class='dialog-close']"));
                    elSendButton   = SeleniumHelper.WaitForElement(By.XPath("//*[@id='compose-dialog-submit']"));
                    // Установить заголовок сообщения
                    elSubject.Clear();
                    firstName = fullName.Split(' ')[0];
                    lastName  = fullName.Split(' ')[1];

                    tmpStr = Settings.BotSettings.SubjectMessage;
                    tmpStr = tmpStr.Replace("%FullName", fullName);
                    tmpStr = tmpStr.Replace("%FirstName", firstName);
                    tmpStr = tmpStr.Replace("%LastName", lastName);
                    elSubject.SendKeys(tmpStr);

                    tmpStr = person.messageText;
                    tmpStr = tmpStr.Replace("%FullName", fullName);
                    tmpStr = tmpStr.Replace("%FirstName", firstName);
                    tmpStr = tmpStr.Replace("%LastName", lastName);
                    elMessage.Clear();
                    elMessage.SendKeys(tmpStr);
                    //elCancelButton.Click();
                    elSendButton.Click();
                    // System.Threading.Thread.Sleep(5000);
                    //        }
                    //        else if (SeleniumHelper.IsElementPresent(By.XPath(".//*[@id='session_key-login']")))
                    //        {
                    //            elLogin.Clear();
                    //        }
                    //        if (SeleniumHelper.IsElementPresent(By.XPath(".//*[@id='session_key-login']")))
                    //        {
                    //            linkedView.Login();
                    //        }
                    //        return false;
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        return false;
                    //    }
                    //}
                    //    return true;
                    //}
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }