java - Selenium PageObject pattern: get objects list -


I have an application page that provides some kind of search and it gives the user a list of search results items. . So my test logs on the application, and starts searching on home page like this:

  homepage homepage = login page. Login (); HomePage.searchFor (item);   

What would be the best way to test for search results, including the expected list items from the design side?

  1. I can add method to return results to page items and then I can do anything with them on the exam square.

      Public Zero Certain Tests (List & gt; Items & gt; Expected Result Items) {... Homepage Home Page = Login Page. Log In (); HomePage.searchFor (item); & Lt; Item & gt; Results item = homePage.getItems (); Utility Commerce Items (as a result, expected candidates); }    
  2. I can add comparison method for page object.

      Public Zero Certain Tests (List & lt; Items & Required Reissent Items) {... Homepage Homepage = loginPage.login (); HomePage.searchFor (item); HomePage.compareItems (list & amp; lt; item is expected); }      

    look and

    There is a lot of flexibility about how page objects can be designed, but there are some basic rules for getting the desired maintenance of your test code. Page objects should never verify themselves or claim it is part of your test and should always be within the test, never in a page object. The page will represent the page object, and any code on the services provided through the methods through the page that is being tested should be within the page object.

    Guidelines based on this first go with one to be accused in the trial and not buried down somewhere in your page object, it is easy to read and understand your test Has been doing.

    It is being said, I personally use another approach and this is mainly because I started this way and now I just use it. That's why I basically have a public method in the page, which is the public null valid search page item (list & lt;? & Gt; required) ... and I make it a different call I am This means that I do not write network methods like getSearchDataAndValidate (list & lt;; & gt; required) , which also calls the valid method so I can use them separately and if If I need this in any other test, then I can reuse the search method without actual verification. You can ask why do not validate your list every time, but if your test suite gets bigger, then it may be reversed in terms of performance

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -