Skip to content

End-to-end testing for Magento2 demo web store, running locally, using Python, pytest and SeleniumBase testing framework.

Notifications You must be signed in to change notification settings

kate-tel/magento2.test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magento 2 End-to-end-testing

Table of Contents

About this Project

This test suite performs end-to-end functional testing for a local demo Magento 2 web store.

Test coverage

Functionality covered by this test suite:

  • Website search and search suggestions;
  • Addding and manipulating items in comparison list;
  • Adding and manipulating items in wish list;
  • Adding and manipulating items in cart;
  • Adding and manipulating items in minicart;
  • Checkout by a registered user;
  • Checkout by a guest;
  • Login;
  • Account creation.

Functionality not covered:

  • Payment method choice. *
  • Order cancellation; *
  • Order amendment; *
  • Password reset; *
  • Account Deletion;
  • Editing account;
  • Contact form Submission;
  • Orders and Returns form Submission;
  • Advanced search;
  • Newsletter subscription; *
  • Review submission;

Functionalities marked with * need additional configuartion to be tested.

Prerequisites

You should have the following installed:

Now, let's look how to get things up and running to use the tests.

Magento installation

  1. First, install MAGENTO 2 using Docker via this link:

    https://github.com/markshust/docker-magento#setup

  2. Choose Automated Setup with sample data.

  3. Note that you will be prompted for your system password during setup.

  4. You should have port 80, 443, 3306 and 9000 available in order to run magento. Here is a video instruction for setup.

  5. During the setup you will be asked to enter you authentification keys. Learn how to create them here.

  6. You will be given your Magento Admin URI. Please save it for the next step. It starts with: https://magento2.test/admin_

  7. After the setup completes running, you should be able to access your site at https://magento2.test.

Configuring Catalog Search

  1. Go to your Magento Admin URI and enter the credentials below: Username: john.smith Password: password123

  2. The default search engine used by Magento is MySQL. To change it to Elasticsearch follow the guide.

  3. Choose the following configurations:

    • Enable Search Suggestions: Yes.
    • Search Suggestions Count: 2.
    • Show Results Count for Each Suggestion: No.

Magento is configured! Let's move on to the next part.

  1. For reference, you can have a look at a demo website, similar to the one tested. This demo website has custom configuration, so tests do not take this into account and shall not be run against it.

Setup of testing environment

In this step the following is installed:

  1. Clone this repository and go to folder
git clone https://github.com/kate-tel/magento2.test.git
cd magento2.test
  1. Install virtualenv
pip3 install -U pip
pip3 install virtualenv
  1. Create & activate virtual env
virtualenv .venv
source .venv/bin/activate
  1. Install requirements. As a result, seleniumbase and pytest will be installed.
pip3 install -r requirements.txt
  1. Install chromedriver
seleniumbase install chromedriver latest

Now project environment is configured and tests can be run.

Running the tests

  1. Specify a test suite to run:
pytest magento/tests/mag_test_search.py
  1. To select a specific test method to run, indicate class name and then method name:
pytest magento/tests/mag_test.py::MagentoTestClass::test_search_fail
  1. Alternatively, you can specify a test to run, using pytest markers. Each test has its own marker for this purpose.

Running a specific test:

pytest magento/tests/mag_test.py -m=minicart
  1. Sometimes page load duration is unstable, so in case of ElementNotVisibleException, running the test(-s) with a custom settings file will help. In this file timeouts are extended, compared to the default ones.

Running a test with custom settings:

pytest magento/tests/mag_test.py -m=search --settings_file=custom_settings.py

Project content

The project consists of two main parts: test suites and page objects files.

.
├── __init__.py
├── custom_settings.py 
├── magento 
│   ├── page_objects
│   │   ├── mag_object_cart.py 
│   │   ├── mag_object_catalog.py 
│   │   ├── mag_object_checkout.py
│   │   └── mag_object_main.py 
│   └── tests
│       ├── __init__.py
│       ├── mag_test.py
│       └── mag_test_search.py
├── pytest.ini
├── README.md
└── requirements.txt

References

  1. For SeleniumBase CLI commands, log saving, configurations etc, please have a look at https://github.com/seleniumbase/SeleniumBase.

  2. List of SeleniumBase methods:

https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py

About

End-to-end testing for Magento2 demo web store, running locally, using Python, pytest and SeleniumBase testing framework.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages