Exemple #1
0
        public void FindFilm(string name)
        {
            name = Uri.EscapeDataString(name);
            var url = string.Format("{1}/#q=" + _appConstants.KinopoiskSearchGoogle, name, GoogleUrl);

            GoToUrl(url);
            var xpath = By.XPath(".//div[@role='main']//a/../..//cite");

            _chrome.ElementIsVisible(xpath);
            var rawFilmLink = _chrome.FindElements(xpath).FirstOrDefault(p => !p.Text.Contains("video"));

            if (rawFilmLink == null)
            {
                throw new FilmNotFoundException();
            }

            var cleanFilmLink = Regex.Match(rawFilmLink.Text, "^[^w]*" + _appConstants.KinopoiskUrl + "\\/film\\/[^\\/]+").Value;

            if (!cleanFilmLink.StartsWith("https://"))
            {
                cleanFilmLink = "https://" + cleanFilmLink;
            }
            GoToUrl(cleanFilmLink);
        }