private void PostAuthInit() { // Ignore the message bar : To help personalize content, tailor and measure ads, and provide a safer experience, we use cookies. By clicking or navigating the site, you agree to allow our collection of information on and off Instagram through cookies. Selenium.ClickIfPresent(Config.CssCookiesWarning); if (!Data.MyContactsUpdate.HasValue || DateTime.UtcNow > Data.MyContactsUpdate.Value.AddHours(Config.BotCacheTimeLimitHours)) { MoveTo(Data.UserContactUrl); WaitHumanizer(); Selenium.Click(Config.CssContactsFollowing); WaitHumanizer(); // ScroolDown SchroolDownLoop(Config.CssContactsListScrollable); // TOFIX : will crash if no contact at all Data.MyContacts = Selenium.GetAttributes(Config.UrlContacts) .ToHashSet(); Log.LogDebug("MyContacts ={0}", Data.MyContacts.Count); Data.MyContactsUpdate = DateTime.UtcNow; } AddForced("AddContactsToFollow", Config.AddContactsToFollow, Data.ContactsToFollow); AddForced("AddPhotosToLike", Config.AddPhotosToLike, Data.PhotosToLike); }
private void ClickWaitIfPresent(string cssSelector) { if (Selenium.ClickIfPresent(cssSelector)) { WaitHumanizer(); } }
private bool TryAuthCookies() { if (Data.Cookies != null && Data.Cookies.Any()) { if (!MoveTo(Config.UrlRoot)) { throw new NotSupportedException("INSTAGRAM RETURN ERROR 500 ON " + Config.UrlRoot); } Selenium.Cookies = Data.Cookies; // need to have loaded the page 1st Selenium.SessionStorage = Data.SessionStorage; // need to have loaded the page 1st Selenium.LocalStorage = Data.LocalStorage; // need to have loaded the page 1st if (!MoveTo(Config.UrlRoot)) { throw new NotSupportedException("INSTAGRAM RETURN ERROR 500 ON " + Config.UrlRoot); } // Ignore the enable notification on your browser modal popup Selenium.ClickIfPresent(Config.CssLoginWarning); //check cookie auth OK : who am i ? Selenium.ClickIfPresent(Config.CssLoginMyself); // if not present, will not fail and next test will detect an error and go for the normal loggin WaitHumanizer(); string curUserContactUrl = Selenium.Url; if (curUserContactUrl != null && curUserContactUrl.EndsWith('/')) // standardize { curUserContactUrl = curUserContactUrl.Remove(curUserContactUrl.Length - 1); } if (Data.UserContactUrl.Equals(curUserContactUrl, StringComparison.OrdinalIgnoreCase)) { Log.LogDebug("User authentified from cookie."); return(true); } else { Log.LogWarning("Couldn't authenticate user from saved cookie."); return(false); } } else { Log.LogDebug("Cookie authentification not used."); return(false); } }
private void AuthLogin() { if (!MoveTo(Config.UrlLogin)) { throw new NotSupportedException("INSTAGRAM RETURN ERROR ON " + Config.UrlLogin); } if (!string.IsNullOrWhiteSpace(Config.BotUserEmail)) { Selenium.InputWrite(Config.CssLoginEmail, Config.BotUserEmail); if (!string.IsNullOrWhiteSpace(Config.BotUserPassword)) { Selenium.InputWrite(Config.CssLoginPassword, Config.BotUserPassword); Selenium.EnterKey(Config.CssLoginPassword); } else { Log.LogWarning("Waiting user manual password validation..."); } WaitUrlStartsWith(Config.UrlRoot); // loading may take some time WaitHumanizer(); // after WaitUrlStartsWith because 1st loading may take extra time // Ignore the notification modal popup Selenium.CrashIfPresent(Config.CssLoginUnusual, "Unusual Login Attempt Detected"); // Ignore the enable notification on your browser modal popup Selenium.ClickIfPresent(Config.CssLoginWarning); // who am i ? Selenium.Click(Config.CssLoginMyself); // must be here, else the auth have failed WaitHumanizer(); Data.UserContactUrl = Selenium.Url; if (Data.UserContactUrl.EndsWith('/')) // standardize { Data.UserContactUrl = Data.UserContactUrl.Remove(Data.UserContactUrl.Length - 1); } Data.CookiesInitDate = DateTime.UtcNow; } else { throw new FormatException("BotUserEmail required !"); } }