Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
156 views
in Technique[技术] by (71.8m points)

c# - Repeateable methods testing while using Page object model

I've created a basic test for checking if some article is displayed and I have a question regarding Page object model. In my solution, I've testing page, base page, map page with element id's, and method page with main logic. Test is something like - open site, navigate to articles, search for 'ArticleX', click on it, add it to the basket, edit the basket. For those operations, I've created 5 tests in my testing page, but now wondering is correct, or I should reduce them? All of them have repeated methods, which I test, for example the last test, called 'Edit basket'. I performing the following operations:

[Test]  
public void TestEditBasket() {  
        logicPage = new LogicPage();  
        logicPage.NavigateTo();
        logicPage.ClickArticles(); 
        logicPage.SearchArticleX();
        logicPage.PressArticleX();   
        logicPage.AddArticleXToBasket(); 
        logicPage.EditBasket(); 

       //this test only checks name, quantity, price when you're editing basket
        Assert.IsTrue(logicPage.ArticleNameInBasket.Text.Contains("ArticleXHeading"));  
        Assert.IsTrue(logicPage.ArticleQuantityInBasket.Text.Contains("1"));   
        Assert.IsTrue(logicPage.ArticlePriceInBasket.Text.Contains("$10")); 

NavigateTo, ClickArticles, SearchArticleX, PressArticleX, AddArticleXToBasket are already tested in the previous tests, but I cannot go directly to the last step - EditBasket, that's why I'm using them in this test. How the other tests looks like:

[Test1]  
    public void VerifyPageOpened() {  
            logicPage = new LogicPage();  
            logicPage.NavigateTo();
             Assert.IsTrue());  
             Assert.IsTrue());

[Test2]  
    public void TestSearchingArticleX() {  
            logicPage = new LogicPage();  
            logicPage.NavigateTo();
            logicPage.ClickArticles();
             Assert.IsTrue());  
             Assert.IsTrue());

[Test3]  
    public void TestClickOnArticleX() {  
            logicPage = new LogicPage();  
            logicPage.NavigateTo();
            logicPage.ClickArticles();
            logicPage.PressArticleX();   
             Assert.IsTrue());
             Assert.IsTrue());

 [Test4]  
    public void TestAddArticleXInBasket() {  
            logicPage = new LogicPage();  
            logicPage.NavigateTo();
            logicPage.ClickArticles();
            logicPage.PressArticleX();  
            logicPage.AddArticleXToBasket();  
             Assert.IsTrue());
             Assert.IsTrue());

I can delete the other tests and left only this one. But will add around of 10 more asserts. Any advice?

question from:https://stackoverflow.com/questions/66060391/repeateable-methods-testing-while-using-page-object-model

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...