WebdriverIO tests. Run with either docker for fast and simple, or install and configure the Repo. A lot of things can also be automated with CI/CD, but I took the liberty not to x(. Also obviously you don't push .env file to the Repo, but this is for simplicity.
I ran into some problems writing the tests specifically for asos.com. It seems they think I am a bot, because they are preventing me from adding items to the basket. I added it as a test case. The error they return
Additionally, asos.com doesn't allow the access to their site with --headless
enabled. Something that could
be fixed in a development environment. For example a pre-production build.
- Run either
start_n_rebuild_docker.bat
orstart_n_rebuild_docker.sh
based on your OS. This will run Selenium-hub container, A Chrome Node container and Build your WebdriverIO image. - Then run WebdriverIO container and save results
docker run -v "$(pwd)/allure-results:/app/webdriver-test/allure-results" --net selenium-grid -it webdriverio
- Create a network for containers
docker network create selenium-grid
- Start Selenium Hub in the network and map ports
docker run -d -p 4442-4444:4442-4444 --net selenium-grid --name selenium-hub selenium/hub:latest
- Start a browser node in the same net. For example, Chrome
docker run -d --net selenium-grid -e SE_EVENT_BUS_HOST=selenium-hub --shm-size="2g" -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 selenium/node-chrome:latest
- Build a Docker image for WebdriverIO.
docker build . -t webdriverio --no-cache
- Run the tests. Copy the allure-results folder from the container to your local machine
-v {%TO_DIR%}:{%FROM_DIR%}
docker run -v "$(pwd)/allure-results:/app/webdriver-test/allure-results" --net selenium-grid -it webdriverio
- Clone the repo
- Install WebdriverIO globally for ease of use
npm install -g webdriverio
- In the project root run
npm install
- Find the version of your current chromedriver. WebdriverIO installs it automatically
npm show chromedriver version
- From https://chromium.cypress.io/ install the browser that fits your version. Move the
chrome-{%OS%}
folder inside the project root. - Change the config file (
wdio.conf.ts
) so the binary path of Chrome is pointing to the binary of the portable browser. (In a larger scale project, you would have your own config)
capabilities: [{ maxInstances: 5, browserName: 'chrome', 'goog:chromeOptions': { binary: './chrome-win/chrome.exe', // This line args: ['--disable-gpu', '--no-sandbox', '--disable-dev-shm-usage', '--window-size=1920,1080'], } }],
- Run the tests
npx wdio wdio.conf.ts
- Get Java 8 or higher
- Install allure globally
npm install -g allure-commandline --save-dev
- Generate the report
npm run generateReport