public static async Task <InstagramPage> GetInstagramPage(Uri url, int maxPostCount) { InstagramPage instagramPage = new InstagramPage(); instagramPage.Url = url; instagramPage.MaxPostCount = maxPostCount; List <string> shortcodes = new List <string>(); //Retrieve instagram page HttpClient client = new HttpClient(); using (var response = await client.GetAsync(url)) { using (var content = response.Content) { string json = await content.ReadAsStringAsync(); JObject jsonResult = JObject.Parse(json); shortcodes = jsonResult.SelectTokens("$.graphql.user.edge_owner_to_timeline_media.edges[*].node.shortcode").Select(s => (string)s).Take(instagramPage.MaxPostCount).ToList(); } } //Retrieve post with pictures instagramPage.InstagramPosts = await GetInstagramPosts(instagramPage, shortcodes); return(instagramPage); }
public void PageHasExpectedTitle() { try { _instagramPage = (InstagramPage)_mainPage.OpenSocialNetwork(SocialNetwork.Instagram); } catch (NoSuchWindowException) { Assert.Fail("Instagram of KyKy was not found"); } }
public void init() { webDriver = new ChromeDriver(ChromeDriverDirectory); webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); webDriver.Manage().Window.Maximize(); mainPage = new MainPage(webDriver); blogPage = new BlogPage(webDriver); howWeDoItPage = new HowWeDoItPage(webDriver); contactPage = new ContactPage(webDriver); instagramPage = new InstagramPage(webDriver); }
private static async Task <List <InstagramPost> > GetInstagramPosts(InstagramPage instagramPage, List <string> shortcodes) { List <InstagramPost> instagramPosts = new List <InstagramPost>(); foreach (var shortCode in shortcodes) { //Retrieve instagram post with pictures HttpClient client = new HttpClient(); Uri url = new Uri(@"https://www.instagram.com/p/" + shortCode + @"/?__a=1", UriKind.Absolute); InstagramPost instagramPost = new InstagramPost(); instagramPost.Pictures = new List <byte[]>(); List <Uri> pictureUrls = new List <Uri>(); using (var response = await client.GetAsync(url)) { using (var content = response.Content) { string json = await content.ReadAsStringAsync(); JObject jsonResult = JObject.Parse(json); try { instagramPost.Message = (string)jsonResult.SelectToken("$.graphql.shortcode_media.edge_media_to_caption.edges[0].node.text"); instagramPost.Likes = (int)jsonResult.SelectToken("$.graphql.shortcode_media.edge_media_preview_like.count"); } catch (Exception) { } pictureUrls = jsonResult.SelectTokens("$.graphql.shortcode_media.edge_sidecar_to_children.edges.[*].node.display_resources[0].src").Select(s => (Uri)s).ToList(); if (pictureUrls.Count == 0) { pictureUrls.Add((Uri)jsonResult.SelectToken("$.graphql.shortcode_media.display_resources[0].src")); } } } foreach (var pictureUrl in pictureUrls) { byte[] picture = await client.GetByteArrayAsync(pictureUrl); instagramPost.Pictures.Add(picture); } instagramPosts.Add(instagramPost); } return(instagramPosts); }
public void TomorrowEventsExist() { _instagramPage = (InstagramPage)_mainPage.OpenSocialNetwork(SocialNetwork.Instagram); Assert.True(_instagramPage.Title.Contains("KYKY.org"), "Instagram's title was changes"); }
public void TodayEventsExist() { _instagramPage = (InstagramPage)_mainPage.OpenSocialNetwork(SocialNetwork.Instagram); Assert.Greater(_instagramPage.Title.Length, 1, "Title of instagram page is too short"); }
public App() { MainPage = new InstagramPage(); }
public App() { InitializeComponent(); MainPage = new InstagramPage(); }