I am new to both Automation and selenium. I am planning to write an automated tests for the UI using selenium web drivers in the py.test. I would like to know what is the best architecture (not the code) for designing the whole automation. The structure I am considering is

Framework level - contains modules for getting the page object, and functions like getItem, logout, login,logging, exceptions, startbrowser, getClickableObject, sendkeysandenter, generate report, waitforresponse, getting and releasing testbeds, loading the webdriver, Global test properties connections or any other generic functions etc

Tests - get the page object, get the item by id, click,sendkeys,verify etc. Basically I want developing the tests to be as simple as possible and anyone can get aboard and write the tests without needing to know the details of implemenation.

Is this a good way for long term maintenance and ease of writing? Any other suggestions are welcome.

Additionally, two more questions.

  • Do I have to store all the pages (something like page map) statically somewhere to verify the pages are loaded correctly. For example, an enter loads a particular page. My main concern with this way is what if the resultant page change? Does the corresponding test cases have to rewritten again?
  • Any action in the UI sends a command to a particular device and changes it properties. The device has a Rest API which returns its properties and this can be used if the changes in the UI is reflected on the device. Ideally, it would be better if this comparison is made for every test. If this might cause too much overhead, this can be made optional. Any better way to carry on this particular aspect?
up vote 4 down vote accepted

Yes and you're definitely ahead of the crowd already with the plan you've laid out.

Additional considerations:

In addition to using a Page Object Model, consider a central place for hard coded values (simple methods that return a string in some cases). So the identifiers for the css locator for last_name are in one place (along with other css element identifiers) and the other 'values' such as 'John' are stored together in one place.

The 'page map' if I understand you correctly will basically be provided by the test framework and webdriver interface. If you are wondering where to store the page object identifier for a given page or set of pages that is largely up to you, your implementation and your preferences. Personally I am inclined towards all identifiers being in one file. Other options are to break the identifiers up by page or by database based fields (and systematically named) in forms all being defined in one place vs. navigation elements being defined in one (or more) other places. The language you use and style of your programmers will also influence this. There are a lot of choices.

Your second question is about the updates getting made (I think). This gets handled by the test framework and by learning about how to do implicit vs explicit waits for specific content for things like AJAX calls.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.