private void GoToPage(int page)
        {
            string pageUrl = $"{bundleRootUrl}?page={page}";

            browserInterface.Navigate(pageUrl);
            browserInterface.WaitForElement(By.ClassName("game_list"));
            currentPage = page;
            currentPageGameRowElements = GetPageGameElements();
            gameRowElementsCount       = currentPageGameRowElements.Count;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieve the information from the game page info widget.
        /// </summary>
        /// <param name="info">Outbound GamePageInfo to store the info in.</param>
        /// <returns>True if the information was retrieved, otherwise False.</returns>
        public bool GetPageInfo(out GamePageInfo info)
        {
            info = new GamePageInfo()
            {
                aggregateRating = 0.0f,
                category        = string.Empty,
                genres          = new string[] { },
                ratingCount     = 0,
                tags            = new string[] { }
            };

            if (browserInterface.Navigate(gameUrl) == false)
            {
                return(false);
            }

            IWebElement infoElement = browserInterface.WaitForElement(By.ClassName("game_info_panel_widget"));

            if (infoElement == null)
            {
                return(false);
            }

            List <IWebElement> infoRows = infoElement.FindElements(By.TagName("tr")).ToList();

            foreach (IWebElement infoRow in infoRows)
            {
                List <IWebElement> rowCells    = infoRow.FindElements(By.TagName("td")).ToList();
                IWebElement        rowNameCell = rowCells[0];
                string             rowNameText = rowNameCell.GetAttribute("textContent");

                switch (rowNameText)
                {
                case "Rating":
                    ParseRatingCell(rowCells[1], ref info);
                    break;

                case "Category":
                    ParseCategoryCell(rowCells[1], ref info);
                    break;

                case "Genre":
                    ParseGenreCell(rowCells[1], ref info);
                    break;

                case "Tags":
                    ParseTagsCell(rowCells[1], ref info);
                    break;
                }
            }

            //It seems on itch that only the Games category does
            //not display a category on the page.
            if (string.IsNullOrEmpty(info.category))
            {
                info.category = "Games";
            }

            return(true);
        }