-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Behatch\Context; | ||
|
||
use Behat\Gherkin\Node\TableNode; | ||
use Behat\Mink\Exception\ExpectationException; | ||
use Behat\Mink\Exception\ResponseTextException; | ||
use Behat\Mink\Exception\ElementNotFoundException; | ||
use WebDriver\Exception\StaleElementReference; | ||
use Behat\Behat\Tester\Exception\PendingException; | ||
|
||
class AccesibilityContext extends BaseContext | ||
{ | ||
/** | ||
* @Then all images should have an alt attribute | ||
*/ | ||
public function allImagesShouldHaveAnAltAttribute() | ||
{ | ||
$images = $this->getSession()->getPage()->findAll('xpath', '//img[not(@alt)]'); | ||
if ($images !== null) { | ||
throw new \Exception("There are images without an alt attribute"); | ||
} | ||
} | ||
|
||
/** | ||
* @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 commentThe reason will be displayed to describe this comment to others. Learn more. Use explicite argument name, like |
||
{ | ||
$title = $this->getSession()->getPage()->find('css', 'h1')->getText(); | ||
if (strlen($title) > $arg1) { | ||
throw new \Exception("The h1 title is more than '$arg1' characters long"); | ||
} | ||
} | ||
|
||
/** | ||
* @Then all tables should have a table header | ||
*/ | ||
public function allTablesShouldHaveATableHeader() | ||
{ | ||
$tables = $this->getSession()->getPage()->findAll('xpath', '//table/*[not(th)]'); | ||
if ($tables !== null) { | ||
throw new \Exception("There are tables without a table header"); | ||
} | ||
} | ||
|
||
/** | ||
* @Then all tables should have at least one data row | ||
*/ | ||
public function allTablesShouldHaveAtLeastOneDataRow() | ||
{ | ||
$tables = $this->getSession()->getPage()->findAll('xpath', '//table/*[not(td)]'); | ||
if ($tables !== null) { | ||
throw new \Exception("There are tables without a data row"); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
@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 commentThe reason will be displayed to describe this comment to others. Learn more. I don’t think it's necessary. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@accesibility | ||
Feature: toegankelijkheid verschillende types paginas | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use english language. |
||
|
||
@accesibility | ||
Scenario Outline: max 1 h1 and min 1 h2 on page | ||
Given I am on "<url>" | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. It’s not necessary if you have only one url. |
||
| url | | ||
| / | | ||
|
||
@accesibility | ||
Scenario Outline: h1 length check | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. It’s not necessary if you have only one url. |
||
| url | | ||
| / | | ||
|
||
@accesibility | ||
Scenario Outline: alt check on images | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. It’s not necessary if you have only one url. |
||
| url | | ||
| / | | ||
|
||
@accesibility | ||
Scenario Outline: check table headers | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. It’s not necessary if you have only one url. |
||
| url | | ||
| / | | ||
|
||
@accesibility | ||
Scenario Outline: check table data | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. It’s not necessary if you have only one url. |
||
| url | | ||
| / | |
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 saidThere are images without an alt attribute