- About this Project
- Test coverage
- Prerequisites
- Magento installation
- Configuring Catalog Search
- Setup of testing environment
- Running the tests
- Project content
- References
This test suite performs end-to-end functional testing for a local demo Magento 2 web store.
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.
You should have the following installed:
Now, let's look how to get things up and running to use the tests.
-
First, install MAGENTO 2 using Docker via this link:
-
Choose Automated Setup with sample data.
-
Note that you will be prompted for your system password during setup.
-
You should have port 80, 443, 3306 and 9000 available in order to run magento. Here is a video instruction for setup.
-
During the setup you will be asked to enter you authentification keys. Learn how to create them here.
-
You will be given your Magento Admin URI. Please save it for the next step. It starts with:
https://magento2.test/admin_
-
After the setup completes running, you should be able to access your site at https://magento2.test.
-
Go to your Magento Admin URI and enter the credentials below: Username:
john.smith
Password:password123
-
The default search engine used by Magento is MySQL. To change it to Elasticsearch follow the guide.
-
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.
- 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.
In this step the following is installed:
- virualenv
- SeleniumBase
- pytest
- chromedriver
- Clone this repository and go to folder
git clone https://github.com/kate-tel/magento2.test.git
cd magento2.test
- Install virtualenv
pip3 install -U pip
pip3 install virtualenv
- Create & activate virtual env
virtualenv .venv
source .venv/bin/activate
- Install requirements. As a result, seleniumbase and pytest will be installed.
pip3 install -r requirements.txt
- Install chromedriver
seleniumbase install chromedriver latest
Now project environment is configured and tests can be run.
- Specify a test suite to run:
pytest magento/tests/mag_test_search.py
- 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
- 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
- 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
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
-
For SeleniumBase CLI commands, log saving, configurations etc, please have a look at https://github.com/seleniumbase/SeleniumBase.
-
List of SeleniumBase methods:
https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py