public ActionResult confirm(AccGoogle recivedData) { if (recivedData != null) { Session["idaccount"] = AccGoogle.LoginGoogle(recivedData, db); return(RedirectToAction("Index", "Home")); } else { return(View("Index")); } }
public bool OpenRegistration(AccGoogle acc) { //79296911370 //using (RegBase regBase = new RegBase()) //{ // google_accs googleAcc = new google_accs() // { // login = acc.Login, // alt_email = acc.AlterEmail, // date_birth = acc.DateBirth, // date_registered = DateTime.Now, // first_name = acc.FirstName, // last_name = acc.LastName, // password = acc.Password, // phone = "79296911370", // sex_id = (int)acc.Sex // }; // regBase.google_accs.Add(googleAcc); // regBase.SaveChanges(); //} //1-я страница driver.Navigate().GoToUrl("https://mail.google.com/mail/signup"); IWebElement element = null; if (!Check2Page()) { throw new Exception("Error in 2 page (registration form)"); } setFirstName(acc.FirstName); setLastName(acc.LastName); //Username setUserName(acc.Login); //Passwd setPassword(acc.Password); //ConfirmPasswd setConfirmPassword(acc.Password); Thread.Sleep(3000); //next click clickNext1(); Thread.Sleep(3000); //3 страница ввода телефона if (!Check3Page()) { throw new Exception("Error in 3 page (input phone)"); } SmsRegApi smsRegApi = new SmsRegApi(acc, settingsDB.SmsRegApiKey); //запрос на номер bool f = smsRegApi.GetNum().GetAwaiter().GetResult(); if (f) { //ввод номера и нажатие кнопки далее for (; ;) { Thread.Sleep(1000); var status = smsRegApi.getState().GetAwaiter().GetResult(); if (status is null) { return(false); } if (status.number != null) { setPhoneNumber(status.number); acc.Phone = status.number; //gradsIdvPhoneNext clickNext2(); smsRegApi.setReady(); break; } } //ввод ответа из смс if (!Check4Page()) { throw new Exception("Error in 4 page (after input phone)"); } for (; ;) { var status = smsRegApi.getState().GetAwaiter().GetResult(); if (status is null) { return(false); } if (status.msg != null) { setCodeFromSms(status.msg); //gradsIdvVerifyNext clickNext3(); smsRegApi.setOperationOk().GetAwaiter().GetResult(); break; } } //та страница, которая содержит поле для ввода альтернативного адреса электронной почты, дата рождения и пол if (!Check5Page()) { throw new Exception("Error in 5 page (alternative email, datebirth and other)"); } //email setAlternativeEmeil(acc.AlterEmail); //day setDay(acc.DateBirth.Day); //month element = driver.FindElement(By.XPath("//select[@id='month']/option[@value='" + acc.DateBirth.Month.ToString() + "']")); element.Click(); //year element = driver.FindElements(By.TagName("input"))[3]; element.SendKeys(acc.DateBirth.Year.ToString()); //Sex element = driver.FindElement(By.XPath("//select[@id='gender']/option[@value='" + (int)acc.Sex + "']")); element.Click(); //button next element = driver.FindElement(By.Id("personalDetailsNext")); element.Click(); //больше возможностей благодаря номеру if (!Check6Page()) { throw new Exception("Error in 6 page (More room features)"); } element = driver.FindElements(By.TagName("button"))[2]; element.Click(); if (!Check7Page()) { throw new Exception("Error in 7 page (Confidentiality and conditions)"); } element = driver.FindElement(By.Id("termsofserviceNext")); element.Click(); if (!Check8Page()) { throw new Exception("Error in 8 page (End Registration)"); } element = driver.FindElement(By.Id("profileIdentifier")); string email = element.Text; if (email.Remove(email.IndexOf('@')).Equals(acc.Login)) { using (RegBase regBase = new RegBase()) { google_accs googleAcc = new google_accs() { login = acc.Login, alt_email = acc.AlterEmail, date_birth = acc.DateBirth, date_registered = DateTime.Now, first_name = acc.FirstName, last_name = acc.LastName, password = acc.Password, phone = acc.Phone, sex_id = (int)acc.Sex }; regBase.google_accs.Add(googleAcc); regBase.SaveChanges(); } return(true); } } ////page3 телефонный номер //element = browser.FindElement(By.Id("countryList")); //var elements = element.FindElements(By.XPath("//div[@class and @data-value]")); //element.Click(); //foreach (var el in elements) //{ // if (el.GetAttribute("data-value").Equals("ru")) // { // el.FindElement(By.TagName("content")).Click(); // break; // } //} return(true); }