Beispiel #1
0
        public HomePage Unfollow(string name)
        {
            name = name.ToLower();
            _followsButton.Click();

            if (!WebElementHelper.HasElementIn(_driver, _followContainer, By.ClassName(FOLLOW_CARD),
                                               TimeSpan.FromSeconds(1)))
            {
                throw new MessageException("Follow is empty");
            }

            if (!WebElementHelper.HasElementIn(_driver, _followContainer, By.Id(name),
                                               TimeSpan.FromSeconds(1)))
            {
                throw new MessageException("Profile not found");
            }

            IWebElement element      = _followContainer.FindElement(By.Id(name));
            IWebElement followButton = element.FindElement(By.ClassName(FOLLOW_BUTTON_CLASS));

            followButton.Click();
            while (WebElementHelper.HasElementIn(_driver, _followContainer, By.Id(name), TimeSpan.FromSeconds(1)))
            {
                ;
            }

            return(this);
        }
Beispiel #2
0
        public HomePage Follow(string name)
        {
            name = name.ToLower();
            this.Navigate();

            _followsButton.Click();
            WebElementHelper.ValueInput(_suggetionInput, name);
            if (!WebElementHelper.HasElementIn(_driver, _suggestionContainer, By.Id(name), TimeSpan.FromSeconds(10)))
            {
                throw new MessageException("Profile not found");
            }

            IWebElement element      = _suggestionContainer.FindElement(By.Id(name));
            IWebElement followButton = element.FindElement(By.ClassName(FOLLOW_BUTTON_CLASS));

            string followButtonText = followButton.Text;

            if (followButtonText == FOLLOW_BUTTON_UNSUBSCRIBE)
            {
                throw new MessageException("Already subscribed");
            }

            followButton.Click();
            while (!WebElementHelper.HasElementIn(_driver, _followContainer, By.Id(name), TimeSpan.FromSeconds(1)))
            {
                ;
            }

            return(this);
        }
Beispiel #3
0
        public List <Post> GetPosts()
        {
            _newsButton.Click();

            if (WebElementHelper.HasElement(_driver, By.ClassName(NO_FOLLOWS_CLASS), TimeSpan.FromSeconds(2)))
            {
                throw new MessageException("No follows");
            }

            if (!WebElementHelper.HasElementIn(_driver, _masonryContainer, By.ClassName(POST_CLASS), TimeSpan.FromSeconds(10)))
            {
                throw new MessageException("Posts not found");
            }

            ReadOnlyCollection <IWebElement> elements = _masonryContainer.FindElements(By.ClassName(POST_CLASS));
            List <Post> posts = new List <Post>();

            foreach (var element in elements)
            {
                string accountName  = element.FindElement(By.ClassName(POST_ACCOUNT_NAME_CLASS)).Text;
                string accountLogin = element.FindElement(By.ClassName(POST_ACCOUNT_LOGIN_CLASS)).Text;
                string contentText  = element.FindElement(By.ClassName(POST_CONTENT_TEXT_CLASS))
                                      .FindElement(By.TagName("p")).Text;
                Post post = new Post()
                {
                    Name  = accountName,
                    Login = accountLogin,
                    Text  = contentText
                };

                posts.Add(post);
            }

            return(posts);
        }
Beispiel #4
0
        public List <FollowUser> GetFollows()
        {
            _followsButton.Click();

            if (!WebElementHelper.HasElementIn(_driver, _followContainer, By.ClassName(FOLLOW_CARD),
                                               TimeSpan.FromSeconds(1)))
            {
                throw new MessageException("Follow is empty");
            }

            ReadOnlyCollection <IWebElement> elements = _followContainer.FindElements(By.ClassName(FOLLOW_CARD));
            List <FollowUser> users = new List <FollowUser>();

            foreach (var element in elements)
            {
                string     name = element.FindElement(By.ClassName(FOLLOW_NICKNAME_CLASS)).Text;
                FollowUser user = new FollowUser()
                {
                    Name = name
                };

                users.Add(user);
            }

            return(users);
        }
Beispiel #5
0
        public FollowUser GetFollowByName(string name)
        {
            _followsButton.Click();

            name = name.ToLower();
            if (!WebElementHelper.HasElementIn(_driver, _followContainer, By.Id(name),
                                               TimeSpan.FromSeconds(1)))
            {
                throw new MessageException("Profile not found");
            }

            IWebElement element  = _followContainer.FindElement(By.Id(name));
            string      nickname = element.FindElement(By.ClassName(FOLLOW_NICKNAME_CLASS)).Text;

            FollowUser user = new FollowUser()
            {
                Name = nickname
            };

            return(user);
        }