We use jenkins CI tool for automated accessibility testing provided by pa11y. As such i use the below Jenkinsfile to run the tests.
node('mypod') { container('centos') { def NODEJS_HOME env.NODEJS_HOME = "${tool 'Node-12.0.0'}" env.PATH="${env.NODEJS_HOME}/bin:${env.PATH}" sh "'${env.NODEJS_HOME}'/bin/node --version" sh "npm install -g pa11y --unsafe-perm" sh "pa11y -V" sh '''curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm yum -y install./google-chrome-stable_current_*.rpm yum -y install libXScrnSaver yum -y install atk java-atk-wrapper at-spi2-atk gtk3 libXt''' withCredentials([file(credentialsId: '***', variable: 'pa11yconfig')]) { sh "cat $pa11yconfig > config.json" sh "pa11y --config config.json --ignore WCAG2AA.Principle3.Guideline3_2.3_2_2.H32.2 --ignore WCAG2AA.Principle1.Guideline1_4.1_4_3.G145.Fail --ignore WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Fail --threshold 6 --reporter cli https://$URL > results.json" } } }
It installs the necessary things to run pa11y against the specified URL on linux based node. Windows are too much of a hassle so we use linux for this implementaion. Also to make this work for the browser to launch we use the below config.json file for pa11y to work.
{ "chromeLaunchConfig": { "args": [ "--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage" ] } }
All of this works like a charm for any URl we provide. Now we would like to have some advanced configurations for lets say test if login works or filling a form on a webpage of a site so may be use Actions provided by pa11y. How should i merge Actions code into this json configuration file to achieve that. Actions is documented under:- https://github.com/pa11y/pa11y#actions
Any help or suggestions here would be greatly appreciated!
Something like this:
"chromeLaunchConfig": {
"args": [
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-dev-shm-usage"
],
},
"reporter": "cli",
"threshold": 6,
"ignore:" [
'WCAG2AA.Principle3.Guideline3_2.3_2_2.H32.2',
'WCAG2AA.Principle1.Guideline1_4.1_4_3.G145.Fail',
'WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Fail'
]
"actions": [
"navigate to $URL",
"wait for $ThingToHappen"
]
}
(I also included options that you're currently passing to the CLI directly, in case that's of interest to you)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.