Giter VIP home page Giter VIP logo

selenium-python-framework's Introduction

Last commit GitHub top language

โš ๏ธ Important notice

I would like to inform everyone who is interested in this project that I decided to go back to working on it. I am planning to implement some major changes like separating framework from tests, adding sample tests for another website than phptravels.com and removing tests implemented before. Thank you guys for forking and giving stars for this project. I appreciate it a lot!

Test Automation Project

This is my first test automation project based on Selenium-Webdriver with Python. It's still developing package of automated tests of phptravels.net demo website. The collection of tests contains:

  • user login tests (correct / incorrect login and password)
  • hotels search tests
  • flights search tests
  • tours search tests
  • transfers search tests

Project Structure

Here you can find a short description of main directories and it's content

  • locators - there are locators of web elements in locators.py grouped in classes
  • pages - there are sets of method for each test step (notice: some repeated methods were moved to functions.py)
  • tests - there are sets of tests for main functionalities of website
  • reports - if you run tests with Allure, tests reports will be saved in this directory
  • utils - this directory contains files responsible for configuration, e.g. driver_factory.py for webdriver management or read_xlsx.py for reading input data from xlsx files included in project

Project Features

  • framework follows page object pattern
  • data-driven tests - in most tests the option of loading data from an xlsx file has been implemented
  • logger has been implemented in each step of test cases, e.g.
@allure.step("Setting destination to '{1}'")
    def set_destination(self, destination):
        self.logger.info(f"Setting destination: {destination}")
        self.driver.find_element(*SearchHotelsFormLocators.destination_inactive).click()

Logs screenshot

  • the ability to easily generate legible and attractive test reports using Allure (for more look Generate Test Report section below)
  • tests can be run on popular browsers - Chrome and Firefox are preconfigured in DriverFactory class and both can be select in conftest.py, e.g.
@pytest.fixture()
def setup(request):
    driver = DriverFactory.get_driver("chrome")

Getting Started

To enjoy the automated tests, develop the framework or adapt it to your own purposes, just download the project or clone repository. You need to install packages using pip according to requirements.txt file. Run the command below in terminal:

$ pip install -r requirements.txt

Run Automated Tests

To run selected test without Allure report you need to set pytest as default test runner in Pycharm first

File > Settings > Tools > Python Integrated Tools > Testing

After that you just need to choose one of the tests from "tests" directory and click "Run test" green arrow. There are 2 versions of test in each test file. In general test cases you can easily modify test inputs. Data-driven tests base on xlsx files from utils directory.

Generate Test Report

To generate all tests report using Allure you need to run tests by command first:

$ pytest --alluredir=<reports directory path>

After that you need to use command:

$ allure serve <reports directory path>

Allure report screenshot

Report is generated in Chrome browser.

selenium-python-framework's People

Contributors

startrug avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.