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(); } }