Code Monkey home page Code Monkey logo

addons-release-tests's Introduction

Release Tests for the Mozilla Addons Website.

Scope

This is an Automation project handled mostly by the AMO QA team. Its goal is to reduce the size of our manual test suites that need to be executed weekly on the AMO staging environment before a new AMO prod release. The current tests are focused mostly on the frontend site, covering areas such as search, homepage UI, add-on installations and other UI elements. The test suites are grouped in individual test files to match the site area they are focused on.

As the project will continue to grow, test areas will be extended to also cover the developer hub pages.

Prerequisites

You'll need to have the following programs installed in your system:

  • Python 3
  • geckodriver
    • if you extract the geckodriver in your main Python directory you can call the driver at runtime from the command line
    • on a Windows machine, python is usually installed in C:\Users\AppData\Local\Programs\Python
  • Docker for Windows

How to run the tests locally

Clone the repository

You'll need to clone this repo using Git. If you do not know how to clone a GitHub repository, check out this help page from GitHub.

If you think you would like to contribute to the tests by writing or maintaining them in the future, it would be a good idea to create a fork of this repository first, and then clone that. GitHub also has great instructions for forking a repository.

Install the dependencies listed in requirements.txt:

  • navigate to the project root directory and run pip install -r requirements.txt

Running tests in the foreground

These tests are meant to be run against the AMO staging environment. We use pytest as our test runner. If you want to see the tests being run on your local machine you can do this simply by navigating to the project directory and running the following command:

pytest --driver Firefox --variables stage.json --variables users.json

You can also run tests from one single test file by specifying the file name:

pytest test_search.py --driver Firefox --variables stage.json --variables users.json

Or you can run a specific test name:

pytest test_search.py::test_name_of_choice --driver Firefox --variables stage.json --variables users.json
  • note that you need to have all the requirements installed for this to work
  • we are using pytest --variables as a tool to store reusable test data
  • make sure that you have a Nightly version installed on your machine if you want the tests to launch in the foreground

Running tests on selenium-standalone with Docker and PowerShell

Before starting, make sure that Docker is up and running and you have switched to Wndows continers.

  • to make the container switch, click on the Docker icon in the system tray and select "Switch to Windows continaers"
  1. Build the selenium-standalone image based on the Dockerfile instructions:
docker image build -t firefox-standalone:latest .
  • note that the process can take a while; you will know that the image was successfully built when docker exits without any errors in the build logs
  1. Once the image is built successfully you can start a container based on it:
docker run -p 4444:4444 --shm-size 2g --rm firefox-standalone:latest
  • the contianer is successfully initialized if you see Selenium Server is up and running on port 4444 as the last entry
  • you can also load localhost:4444 in your browser and make sure you see the Selenium-standalone homepage
  1. To run the tests inside the selenium-standalone container, you need to point pytest to port 4444:
pytest test_name.py --driver Remote --port 4444 --capability browserName firefox --variables stage.json
  • we use --driver Remote and --port 4444 because we want to tell our tests to run against the Selenium-standalone server inside our container
  • the tests will run headless (the browser should not open). If the browser opens, your set-up might not be correct

Adding a test

The tests are written in Python using a POM, or Page Object Model. The plugin we use for this is called pypom. Please read the documentation there for good examples on how to use the Page Object Model when writing tests.

The pytest plugin that we use for running tests has a number of advanced command line options available too. The full documentation for the plugin can be found here.

Mobile and Desktop testing

If you would like to add or edit tests please consider that these are run on both a mobile resolution and a desktop resolution. The mobile resolution is 738x414 (iPhone 7+), the desktop resolution is: 1920x1080. Your tests should be able to work on both.

Debugging a failure

Whether a test passes or fails will result in a HTML report being created. This report will have detailed information of the test run and if a test does fail, it will provide geckodriver logs, terminal logs, as well as a screenshot of the browser when the test failed. We use a pytest plugin called pytest-html to create this report. The report can be found within the project directory and is named ui-test.html. It should be viewed within a browser.

addons-release-tests's People

Contributors

alexandramoga avatar alexandruschek avatar anyesh avatar b4handjr avatar cristian0995 avatar dependabot[bot] avatar kushalbeniwal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

addons-release-tests's Issues

Add new mobile tests

Since AMO is always changing on Fenix (mobile) it would be nice to make sure we can test this a bit. This is just a tracking issue for that effort.

Add open source software license

This Mozilla repository has been identified as lacking a license. Consistent with Mozilla's Licensing Policy an open source license should be applied to the code in this repository.

Please add an appropriate LICENSE.md file to the root directory of the project. In general, Mozilla's licensing policies are as follows:

  • Client-side products created by Mozilla employees or contributors should use the Mozilla Public License, Version 2.0 (MPL).

  • Server-side products or utilities that support Mozilla products may use either the MPL or the Apache License 2.0 (Apache 2.0).

In special cases, another license might be appropriate. If the repository is a fork of another repository it must apply the license of the original. Similarly, another license might be appropriate to match that of a broader project (for example Rust crates that Firefox depends on are published under an Apache 2.0 / MIT dual license, as that is the dual license used by the Rust programming language and projects).

Please ensure that any license added to the LICENSE.md file matches other licensing information in the repository (for example, it should match any license indicated in a setup.py or package.json file).

Mozilla staff can access more information in our Software Licensing Runbook – search for “Licensing Runbook” in Confluence to find it.

If you have any questions you can contact Daniel Nazer who can be reached at dnazer on Mozilla email or Slack.

OPENLIC-2023-01

Switch to single quote strings

Currently we are using a mix of single(') and double (") quote strings in our code. We should be using a unified format - and I favor single quote strings.

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.