added a few accesibility checks. more to come.#202
added a few accesibility checks. more to come.#202marijndaniels wants to merge 5 commits intoBehatch:masterfrom
Conversation
sanpii
left a comment
There was a problem hiding this comment.
Great idea!
Please add a test for these definitions.
It’s maybe a good idea to add a reference from w3c standard in error messages. For example, in the first text error message, I have added a link to https://www.w3.org/TR/WCAG10/#gl-provide-equivalents
src/Context/AccesibilityContext.php
Outdated
| @@ -0,0 +1,49 @@ | |||
| <?php | |||
|
|
|||
| namespace Sanpi\Behatch\Context; | |||
There was a problem hiding this comment.
Since the last version, the right namespace is Behatch\Context.
src/Context/AccesibilityContext.php
Outdated
| class AccesibilityContext extends BaseContext | ||
| { | ||
|
|
||
| public function __construct() |
src/Context/AccesibilityContext.php
Outdated
| public function allImagesShouldHaveAnAltAttribute() | ||
| { | ||
| $images = $this->getSession()->getPage()->findAll('xpath', '//img[not(@alt)]'); | ||
| if ($images != null) { |
src/Context/AccesibilityContext.php
Outdated
| public function allTablesShouldHaveATableHeader() | ||
| { | ||
| $tables = $this->getSession()->getPage()->findAll('xpath', '//table/*[not(th)]'); | ||
| if ($tables != null) { |
|
|
||
| @trigger_error('The Sanpi\\Behatch\\Context\\AccesibilityContext class is deprecated since version 2.3 and will be removed in 3.0. Use the Behatch\\Context\\AccesibilityContext class instead.', E_USER_DEPRECATED); | ||
|
|
||
| class_alias('\\Behatch\\Context\\AccesibilityContext', '\\Sanpi\\Behatch\\Context\\AccesibilityContext'); |
| @@ -0,0 +1,48 @@ | |||
| @accesibility | |||
| Feature: toegankelijkheid verschillende types paginas | |||
| Then I should see 1 "h1" elements | ||
| And I should see an "h2" element | ||
|
|
||
| Examples: |
There was a problem hiding this comment.
It’s not necessary if you have only one url.
| Given I am on "<url>" | ||
| Then the title should not be longer than 70 | ||
|
|
||
| Examples: |
There was a problem hiding this comment.
It’s not necessary if you have only one url.
| Given I am on "<url>" | ||
| Then all images should have an alt attribute | ||
|
|
||
| Examples: |
There was a problem hiding this comment.
It’s not necessary if you have only one url.
| Given I am on "<url>" | ||
| Then all tables should have a table header | ||
|
|
||
| Examples: |
There was a problem hiding this comment.
It’s not necessary if you have only one url.
| Given I am on "<url>" | ||
| Then all tables should have at least one data row | ||
|
|
||
| Examples: |
There was a problem hiding this comment.
It’s not necessary if you have only one url.
| /** | ||
| * @Then the title should not be longer than :arg1 | ||
| */ | ||
| public function theTitleShouldNotBeLongerThan($arg1) |
There was a problem hiding this comment.
Use explicite argument name, like $length
| */ | ||
| public function allImagesShouldHaveAnAltAttribute() | ||
| { | ||
| $images = $this->getSession()->getPage()->findAll('xpath', '//img[not(@alt)]'); |
There was a problem hiding this comment.
Hi, could you tell me this would refer to test image without alt?
I pull your code and test my website. There are alt attribute, but still said There are images without an alt attribute
Extending the BaseContext for some accesibility checks.
Plan to add these as well:
** each page should have one and only one H1 element.
** the H1 element should not be longer than 70 chars in length.
** each page should have at least one H2 element
** Each image should have an alt attribute, possibly empty.
** If a title attribute is present, it should differ in value from the alt attribute
** for each a:hover there should also be an a:focus
** title attribute should differ in value from the text in between the a tags
** each formfield should have a label
** all labels should have a for attribute, linked to the formfield
** check for skip navigation
** check doctype present
** check lang attribute