To check missing dependencies on linux machine run below command
ldd chrome | grep
gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc
There are two ways to setup sandbox in chromium:
Enable user namespace cloning:
sudo sysctl -w kernel.unprivileged_userns_clone=1
Setup setuid sandbox:
Follow steps given here to setup setuid sandbox
To disable sandboxing launch chromium with below arguments:
await openBrowser({args: ['--no-sandbox', '--disable-setuid-sandbox']});
To run Taiko in a docker container follow these instructions:
docker pull node
Start a container
docker run node -it /bin/bash
Update packages
apt-get update
Install chromium dependencies
apt-get install -y wget unzip fontconfig locales gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils
Install Taiko
npm install taiko -g --allow-root --unsafe-perm=true
To launch taiko in headless mode start taiko REPL with taiko and open browser with below arguments:
await openBrowser({headless: true, args: ['--no-sandbox']});
To launch taiko in headful mode install Xvfb
apt-get install xvfb
Start taiko REPL with xvfb-run taiko and open browser with below arguments:
await openBrowser({headless: false, args: ['--no-sandbox']});
To improve load time when running tests in parallel on cloud, following chromium command line args are recommended
await openBrowser({args: [
'--disable-gpu',
'--disable-dev-shm-usage',
'--disable-setuid-sandbox',
'--no-first-run',
'--no-sandbox',
'--no-zygote']});
Run with below env to enable debug logs
env DEBUG="taiko:*" taiko code.js
Taiko by default waits for any network requests that are triggered as part of the action, frame load, frame navigation and new target navigation events. Navigation actions like goto, reload waits for loadEventFired in addition. There can be scenarios where the action might take time to trigger events, hence could be missed by taiko. Below are few where waiting for appropriate events will improve performance and reduce flakyness in tests.
firstMeaningfulPaint - Wait for this event if an action can trigger a page load which has heavy image or fonts to loaded.
targetNavigated - Wait for this event if there is a new tab/window open or close that happens because of an action.
loadEventFired - Wait for this event if an action triggers a page load which is not instanteneous.
Example:
await click(link('open new tab'),{waitForEvents:['targetNavigated']})