-
Notifications
You must be signed in to change notification settings - Fork 203
added a few accesibility checks. more to come. #202
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the last version, the right namespace is Behatch\Context
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also test added
src/Context/AccesibilityContext.php
Outdated
class AccesibilityContext extends BaseContext | ||
{ | ||
|
||
public function __construct() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No empty construct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/Context/AccesibilityContext.php
Outdated
public function allImagesShouldHaveAnAltAttribute() | ||
{ | ||
$images = $this->getSession()->getPage()->findAll('xpath', '//img[not(@alt)]'); | ||
if ($images != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use strict (===
) equality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/Context/AccesibilityContext.php
Outdated
public function allTablesShouldHaveATableHeader() | ||
{ | ||
$tables = $this->getSession()->getPage()->findAll('xpath', '//table/*[not(th)]'); | ||
if ($tables != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use strict (===
) equality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
@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'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think it's necessary.
@@ -0,0 +1,48 @@ | |||
@accesibility | |||
Feature: toegankelijkheid verschillende types paginas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use english language.
Then I should see 1 "h1" elements | ||
And I should see an "h2" element | ||
|
||
Examples: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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