コード例 #1
0
        internal bool HasNestedComment(ExampleComment exampleComment, ExampleComment responseComment)
        {
            var comments = browser.FindElements(By.CssSelector(".comment"));


            var myComments = comments.Where(ExampleComment(exampleComment));

            var myCommentsOtherWay = comments.Where(c => c.FindElement(By.ClassName("fn")).Text == exampleComment.Author &&
                                                    c.FindElement(By.ClassName("comment-content")).Text == exampleComment.Comment);

            var myCommentsYetAnotherWay = comments
                                          .Where(c => c.FindElement(By.ClassName("fn")).Text == exampleComment.Author)
                                          .Where(c => c.FindElement(By.ClassName("comment-content")).Text == exampleComment.Comment);


            var firstCommentChildren = comments.First().FindElements(By.CssSelector(".children"));


            var nestedComment = browser.FindElement(By.XPath("//*[@class=\"children\"]//*[contains(text(), \""
                                                             + responseComment.Author + "\")]/../../../../../..//*[contains(text(), \""
                                                             + exampleComment.Author + "\")]"));

            //   var myComment = nestedComments
            //      .Where(c => c.FindElement(By.CssSelector(".fn")).Text == responseComment.Author)
            //     .Where(c => c.FindElement(By.CssSelector(".comment-content > p")).Text == responseComment.Comment);
            //   return myComment.Count() == 1;
            int a = 1;

            return(true);
        }
コード例 #2
0
        internal bool Has(ExampleComment exampleComment)
        {
            var comments   = _browser.FindElements(By.CssSelector("article.comment-body"));
            var myComments = comments
                             .Where(c => c.FindElement(By.CssSelector(".fn")).Text == exampleComment.Author) //ma być takie samo ==
                             .Where(c => c.FindElement(By.CssSelector(".comment-content > p")).Text == exampleComment.Content);

            return(myComments.Count() == 1);//Assercja!
        }
コード例 #3
0
ファイル: CommentTests.cs プロジェクト: wiolawiola/wiolawiola
        public void Can_add_new_comment_to_latest_note()
        {
            var blogStartPage   = MainPage.Open(GetBrowser());
            var notePage        = blogStartPage.NavigateToNewesNote();
            var exampleComment  = new ExampleComment();
            var noteWithComment = notePage.AddComent(exampleComment);

            Assert.True(noteWithComment.Has(exampleComment));
        }
コード例 #4
0
        public void CanAddNewCommentToLatestNote()
        {
            var startPage       = MainPage.Open(GetBrowser()); //c# czytamy od prawej do lewej Open-metoda fabryczna(tworzenie obiektów)
            var note            = startPage.NavigateToNewestNote();
            var testComment     = new ExampleComment();
            var noteWithComment = note.ExampleNote(testComment);

            Assert.True(noteWithComment.Has(testComment)); //tu moze byc Asercja, nie w klasie
        }
コード例 #5
0
        internal bool Has(ExampleComment exampleComment)
        {
            var comments  = browser.FindElements(By.ClassName("comment-body"));
            var myComment = comments
                            .Where(c => c.FindElement(By.CssSelector(".fn")).Text == exampleComment.Author)
                            .Where(c => c.FindElement(By.CssSelector(".comment-content > p")).Text == exampleComment.Comment);

            return(myComment.Count() == 1);
        }
コード例 #6
0
        public void CanAddNewCommentToLatestNote()
        {
            var blogStartPage   = MainPage.Open(GetBrowser());
            var note            = blogStartPage.NavigateToNewestNote();
            var exampleComment  = new ExampleComment();
            var noteWithComment = note.AddComment(exampleComment);

            Assert.True(noteWithComment.Has(exampleComment));
        }
コード例 #7
0
        public void CanAddCommentToComment()
        {
            var blogStartPage   = MainPage.Open(GetBrowser());
            var note            = blogStartPage.NavigateToNewestNote();
            var exampleComment  = new ExampleComment();
            var noteWithComment = note.AddComment(exampleComment);
            //  Assert.True(noteWithComment.Has(exampleComment));
            var responseComment = new ExampleComment();

            noteWithComment.ResponseToComment(exampleComment, responseComment);
            Assert.True(noteWithComment.HasNestedComment(exampleComment, responseComment));
        }
コード例 #8
0
        internal NotePage ExampleNote(ExampleComment exampleComment)//3 zmienne, klasa "ExampleComment" jest kontenerem na 3 zmienne, przekazujemy email, komentarz i autora
        {
            var comment = _browser.FindElement(By.Id("comment"));

            comment.SendKeys(exampleComment.Content);

            var author = _browser.FindElement(By.Id("author"));

            author.SendKeys(exampleComment.Author);

            var email = _browser.FindElement(By.Id("email"));

            email.SendKeys(exampleComment.Email);

            MoveToElement(_browser.FindElement(By.CssSelector("div.nav-links")));

            _browser.FindElement(By.Id("submit")).Submit();

            return(new NotePage(_browser));
        }
コード例 #9
0
        internal NotePage AddComment(ExampleComment exampleComment)
        {
            var comment = browser.FindElement(By.Id("comment"));

            comment.SendKeys(exampleComment.Content);

            var author = browser.FindElement(By.Id("author"));

            author.SendKeys(exampleComment.Author);

            var email = browser.FindElement(By.Id("email"));

            email.SendKeys(exampleComment.Email);

            MoveToElement(browser.FindElement(By.CssSelector(".nav-links")));

            browser.FindElement(By.Id("submit")).Submit();

            return(new NotePage(browser));
        }
コード例 #10
0
        internal NotePage AddComent(ExampleComment exampleComment)
        {
            var queryBoxComment = _browser.FindElement(By.Id("comment"));

            queryBoxComment.SendKeys(exampleComment.Content);

            var queryBoxAuthot = _browser.FindElement(By.Id("author"));

            queryBoxAuthot.SendKeys(exampleComment.Author);

            var queryBoxEmail = _browser.FindElement(By.Id("email"));

            queryBoxEmail.SendKeys(exampleComment.Email);

            MoveToElement(_browser.FindElement(By.CssSelector("div.nav-links")));
            var PublishComment = _browser.FindElement(By.Id("submit"));

            PublishComment.Click();


            return(new NotePage(_browser));
        }
コード例 #11
0
        internal NotePage ResponseToComment(ExampleComment exampleComment, ExampleComment responseComment)
        {
            browser.FindElement(By.XPath("//*[contains(@aria-label, '" + exampleComment.Author + "')]")).Click();
            var comment = browser.FindElement(By.Id("comment"));

            comment.SendKeys(responseComment.Comment);

            var author = browser.FindElement(By.Id("author"));

            author.SendKeys(responseComment.Author);

            var email = browser.FindElement(By.Id("email"));

            email.SendKeys(responseComment.Email);

            var submitButton = browser.FindElement(By.Id("submit"));

            MoveToElement(browser.FindElement(By.CssSelector("div.nav-links")));
            submitButton.Submit();

            return(new NotePage(browser));
        }
コード例 #12
0
 private Func <IWebElement, bool> ExampleComment(ExampleComment exampleComment)
 {
     return(x => x.FindElement(By.ClassName("fn")).Text == exampleComment.Author);
 }