public void NavigatorSwap()
        {
            var driver = new ChromeDriver(@"C:\Program Files")
            {
                Url = "https://fantasy.espn.com/football/team?leagueId=61483480&teamId=10&seasonId=2019"
            };

            var navigator = new ESPNNavigator(driver);

            navigator.LogIn();
            var table = navigator.GetTable();
            var row   = navigator.GetRow(table, 1);

            navigator.ClickRosterAction(row);
            Thread.Sleep(1000);
            row = navigator.GetRow(table, 10);
            navigator.ClickRosterAction(row);

            driver.Close();
        }
        public void JavascriptTest()
        {
            ChromeDriver driver = new ChromeDriver(@"C:/Program Files");

            driver.Url = "https://fantasy.espn.com/football/team?leagueId=61483480&teamId=10";

            var executor = (IJavaScriptExecutor)driver;

            /*for (int i = 0; i < 4; i++)
             * {
             *  executor.ExecuteScript("window.scrollBy(0,200)");
             *  Thread.Sleep(1000);
             * }
             * driver.Close();*/
            var navigator = new ESPNNavigator(driver);
            var table     = navigator.GetTable();
            var row       = navigator.GetRow(table, 15);

            navigator.ScrollElementIntoView(row);
            row = navigator.GetRow(table, 1);
            navigator.ScrollElementIntoView(row);
            driver.Close();
        }
Beispiel #3
0
        /// <summary>
        /// Retrieves a free agent for a position and swaps him for a position
        /// </summary>
        /// <param name="pos">The position of the player to pick up</param>
        /// <param name="dropPlayer">The player to drop</param>
        /// <param name="useWaivers">Whether or not to include players from waivers</param>
        public void AddFreeAgent(Position pos, Player dropPlayer, bool useWaivers)
        {
            if (url != FREE_AGENTS_URL)
            {
                url        = FREE_AGENTS_URL;
                driver.Url = url;
            }
            if (!isLoggedIn)
            {
                LogIn();
            }
            navigator.ClickPositionTab(pos);

            //select new player
            var    table  = navigator.GetTable();
            Player best   = null;
            int    bestId = 0;

            for (int i = 0; i < 10; i++)
            {
                var    pRow        = navigator.GetRow(table, i);
                Player p           = navigator.ReadPlayerRow(pRow, ESPNNavigator.PlayerTable.FreeAgent);
                bool   isClickable = navigator.IsFreeAgentClickable(pRow, useWaivers);
                if (isClickable && (best == null || p.CompareTo(best) > 0))
                {
                    best   = p;
                    bestId = i;
                }
            }
            logger.Info("Selected free agent " + best);
            var bestRow = navigator.GetRow(table, bestId);

            navigator.ClickFreeAgentAction(bestRow);

            //select player to drop
            int         n   = 1;
            IWebElement row = null;

            while (navigator.TableExists(n))
            {
                table = navigator.GetTable(n);
                try
                {
                    row = navigator.GetRow(table, dropPlayer, PlayerTable.Roster);
                    break;
                } catch { }
                n++;
            }

            if (row == null)
            {
                navigator.ClickCancel();
                logger.Error("Player " + dropPlayer + " could not be located to be dropped");
                throw new NotFoundException("Player " + dropPlayer + " could not be located to be dropped");
            }
            //confirm action
            navigator.ClickRosterAction(row);
            navigator.ClickContinue();
            navigator.ClickConfirm();
            logger.Info(dropPlayer + "successfully replaced by " + best);
        }