UI Automation
UI automation using Selenium getting a good buzz since selenium had come up with Webdriver which provides useful and essential methods, properties and frameworks to automate web UI. Programming languages like Java, Python, C#, etc. are widely used with selenium to automate web applications. In this article, we are going to talk about how python can be used with selenium web driver for creating test automation scripts.
How to build an automation framework
A framework is basically a way of creating a kind of prototype to structure and organize your test automation scripts so that they can be easily run and maintained throughout the lifecycle of your test.
Python provides various inbuilt modules with the help of which an efficient framework can be built using selenium. 
  1. Unittest
  2. Pytest
  3. Page object model
  4. Data driven testing
  5. Behaviour driver development (BDD)
Using a combination of all the above framework techniques, hybrid automation framework can be created by following below standards,
  • All the generic methods or static methods that are reusable in nature irrespective of your web application can be created under a class called base class and should be organized in the 'Base' directory of your project.
  • Page object model feature enables you to create a test script of every individual web page of your web application and such test scripts can be organized in a directory/package called Page.
  • Test methods should be created for all your test cases under test class which can be stored in the 'Tests' directory/package of your framework.
  • All the screenshots captured from the test methods should be saved and stored in the 'Screenshots' directory/package of your framework.
  • All your behavior-driven tests (business use cases/scenarios) should be kept and stored under the 'BDD' directory/package.
  • While using pytest you need to make sure that all your test methods should follow certain naming conventions like 
  • All the test methods should start with 'test' keyword.
  • The class name should start with the 'test' keyword. The typical folder structure should look like:
Framework structure 
  • For BDD using behave, a feature file should be created containing use cases/business scenarios in the below format and this feature file should be kept under Feature folder/directory.
        Feature:
                  Scenario:
                         Given:
                         When:
                         Then:
  • steps directory should contain steps.py file containing step implementation for your scenario defined in the feature file.
              BDD
                 ---features
                      --steps
                          ---steps.py
                     --<filename>.feature
  • Various reports can be generated for test runs like the Html report, Allure report to capture test results.
  • With the help of the inbuilt logging module, logs can be generated for required events/actions.


Comments

Popular Posts

Image