internal ContactUsPage NavigateToContactUs() { WebElementExtensions.MoveToElement(SecurepaySupport); WebDriverExtensions.WaitForElement(DriverContext.Driver, SecurepayContactUs, 10); SecurepayContactUs.Click(); return(GetInstance <ContactUsPage>()); }
internal ResultsPage GoogleSearch(string text) { googleSearchTextBox.SendKeys(text); WebDriverExtensions.WaitForElement(DriverContext.Driver, googleSearchButton, 10); googleSearchButton.Submit(); return(GetInstance <ResultsPage>()); }
public void Login(string username, string password) { _driver.Navigate().GoToUrl("http://www.instagram.com/accounts/login"); _webHelper.WaitForElement(By.CssSelector(".K-1uj"), 5000); UsernameField.SendKeys(username); PasswordField.SendKeys(password); LoginButton.Click(); //.piCib is the alert that pops up when you first log in. The drivers don't save cookies, //so each run will be a "new" login. //COOzN is the sidebar, lower in the DOM. Hopefully the user is fully logged in by the time this is found. //TODO figure out what I'm doing here _webHelper.WaitForElement(By.CssSelector(".COOzN"), 2000); }
public void SaveStoryContent() { try { _webHelper.WaitForElement(By.CssSelector("._7zQEa"), 2000); if (StoryVideoSrcClass.Any()) { _tempLinkList.Add(StoryVideoSrcClass.First().GetAttribute("src")); } else if (StoryImageSrcClass.Any()) { foreach (var webElement in StoryImageSrcClass) { var stringList = webElement.GetAttribute("srcset").Split(','); var index = Array.FindIndex(stringList, row => row.Contains("1080w")); _tempLinkList.Add(stringList[index].Remove(stringList[index].Length - 6)); } } if (_tempLinkList.Count < StoryPageNavigationClass.Count()) { StoryChevronClass.Click(); SaveStoryContent(); } else { var currentDateTime = DateTime.Now.ToString("yyyy-MM-dd"); for (var i = 0; i < _tempLinkList.Count; i++) { _targetStory.Post(new KeyValuePair <string, string>(currentDateTime + " story " + (_tempLinkList.Count - i), _tempLinkList[i])); } Logger.Info("Story Capture Complete"); _targetStory.Complete(); StoryChevronClass.Click(); } } catch (Exception ex) { Logger.Error(ex, "There's a good chance your password is wrong"); } }
public void GetPostData() { try { _webHelper.WaitForElement(By.CssSelector(".eo2As"), 2000); if (MultiSrcPostChevron != null) { if (VideoSourceClass.Any()) { foreach (var webElement in VideoSourceClass) { _tempLinkList.Add(webElement.GetAttribute("src")); } } else if (ImageSourceClass.Any()) { foreach (var webElement in ImageSourceClass) { if (!webElement.GetAttribute("srcset").Contains("1080w")) { continue; } var stringList = webElement.GetAttribute("srcset").Split(','); var index = Array.FindIndex(stringList, row => row.Contains("1080w")); _tempLinkList.Add(stringList[index].Remove(stringList[index].Length - 6)); } } MultiSrcPostChevron.Click(); GetPostData(); } else { if (VideoSourceClass.Any()) { foreach (var webElement in VideoSourceClass) { _tempLinkList.Add(webElement.GetAttribute("src")); } } else if (ImageSourceClass.Any()) { foreach (var webElement in ImageSourceClass) { if (!webElement.GetAttribute("srcset").Contains("1080w")) { continue; } var stringList = webElement.GetAttribute("srcset").Split(','); var index = Array.FindIndex(stringList, row => row.Contains("1080w")); _tempLinkList.Add(stringList[index].Remove(stringList[index].Length - 6)); } } _tempLinkList = _tempLinkList.Distinct().ToList(); var timeStamp = _webHelper.RefineTimeStamp(); if (_targetText != null) { GetComments(timeStamp); } for (var i = 0; i < _tempLinkList.Count; i++) { _targetMedia.Post(new KeyValuePair <string, string>(timeStamp + " " + (_tempLinkList.Count - i), _tempLinkList[i])); } if (NextPostPaginationArrow != null) { NextPostPaginationArrow.Click(); _tempLinkList.Clear(); if (_targetText != null) { new PostPage(_driver, _targetMedia).GetPostData(); } else { new PostPage(_driver, _targetMedia, _targetText).GetPostData(); } } else { _targetMedia.Complete(); _targetText?.Complete(); Logger.Info("Finished capture of post data"); } } } catch (StaleElementReferenceException) { Logger.Error("Stale Element, Retrying"); GetPostData(); } }