Example #1
0
        private List <string> NicksDeUsuariosRelacionados(int cantidadQueSeDebeConseguir)
        {
            var relacionadosLinkElements = _browser.FindElements(By.CssSelector("ul>div>li>div>div>div>div>a"));

            var cantidadIteracionAnterior = 0;

            while (cantidadQueSeDebeConseguir > relacionadosLinkElements.Count + 2)             //Siempre hay uno o dos que no los consigue, no sé por qué
            {
                EsperarEntre(2000, 3000);
                _browser.Scroll(5000, 10000);

                relacionadosLinkElements = _browser.FindElements(By.CssSelector("ul>div>li>div>div>div>div>a"));

                if (cantidadIteracionAnterior == relacionadosLinkElements.Count)
                {
                    throw new Exception($"Debían conseguirse {cantidadQueSeDebeConseguir} y se consiguieron {cantidadIteracionAnterior}.");
                }

                cantidadIteracionAnterior = relacionadosLinkElements.Count;
            }

            Log.Info($"Debían conseguirse {cantidadQueSeDebeConseguir} y se consiguieron {cantidadIteracionAnterior}.");
            return(relacionadosLinkElements.Select(x => x.Text).ToList());
        }