From 85fb5aa35349e67c5726f5684afae4942e5657d1 Mon Sep 17 00:00:00 2001 From: Marijn Daniels Date: Tue, 7 Mar 2017 10:14:03 +0100 Subject: [PATCH 1/5] added a few accesibility checks. more to come. --- src/Context/AccesibilityContext.php | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/Context/AccesibilityContext.php diff --git a/src/Context/AccesibilityContext.php b/src/Context/AccesibilityContext.php new file mode 100644 index 00000000..f7b0d3d0 --- /dev/null +++ b/src/Context/AccesibilityContext.php @@ -0,0 +1,49 @@ +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) + { + $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"); + } + } +} From 83e3e5ceba9e583324b52db33c177971aafd1510 Mon Sep 17 00:00:00 2001 From: Marijn Daniels Date: Tue, 7 Mar 2017 12:48:04 +0100 Subject: [PATCH 2/5] removed constructor and used strict value&type comparison --- src/Context/AccesibilityContext.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Context/AccesibilityContext.php b/src/Context/AccesibilityContext.php index f7b0d3d0..735ab72d 100644 --- a/src/Context/AccesibilityContext.php +++ b/src/Context/AccesibilityContext.php @@ -9,18 +9,13 @@ class AccesibilityContext extends BaseContext { - - public function __construct() - { - } - /** * @Then all images should have an alt attribute */ public function allImagesShouldHaveAnAltAttribute() { $images = $this->getSession()->getPage()->findAll('xpath', '//img[not(@alt)]'); - if ($images != null) { + if ($images !== null) { throw new \Exception("There are images without an alt attribute"); } } @@ -42,8 +37,19 @@ public function theTitleShouldNotBeLongerThan($arg1) public function allTablesShouldHaveATableHeader() { $tables = $this->getSession()->getPage()->findAll('xpath', '//table/*[not(th)]'); - if ($tables != null) { + 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"); + } + } } From 896ea3aa437d27c3065c4ecc9e59bf78d69d6312 Mon Sep 17 00:00:00 2001 From: Marijn Daniels Date: Tue, 7 Mar 2017 13:51:51 +0100 Subject: [PATCH 3/5] changed namespace --- src/Context/AccesibilityContext.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Context/AccesibilityContext.php b/src/Context/AccesibilityContext.php index 735ab72d..24aed743 100644 --- a/src/Context/AccesibilityContext.php +++ b/src/Context/AccesibilityContext.php @@ -1,11 +1,13 @@ Date: Tue, 7 Mar 2017 13:55:52 +0100 Subject: [PATCH 4/5] test added for accesibility feature --- tests/features/accesibility.feature | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/features/accesibility.feature diff --git a/tests/features/accesibility.feature b/tests/features/accesibility.feature new file mode 100644 index 00000000..cc9ad56b --- /dev/null +++ b/tests/features/accesibility.feature @@ -0,0 +1,48 @@ + @accesibility + Feature: toegankelijkheid verschillende types paginas + + @accesibility + Scenario Outline: max 1 h1 and min 1 h2 on page + Given I am on "" + Then I should see 1 "h1" elements + And I should see an "h2" element + + Examples: + | url | + | / | + + @accesibility + Scenario Outline: h1 length check + Given I am on "" + Then the title should not be longer than 70 + + Examples: + | url | + | / | + + @accesibility + Scenario Outline: alt check on images + Given I am on "" + Then all images should have an alt attribute + + Examples: + | url | + | / | + + @accesibility + Scenario Outline: check table headers + Given I am on "" + Then all tables should have a table header + + Examples: + | url | + | / | + + @accesibility + Scenario Outline: check table data + Given I am on "" + Then all tables should have at least one data row + + Examples: + | url | + | / | \ No newline at end of file From e3060e234bab61faf34779125d0e12271b2d68a1 Mon Sep 17 00:00:00 2001 From: Marijn Daniels Date: Tue, 7 Mar 2017 17:05:27 +0100 Subject: [PATCH 5/5] added class alias --- src/class_aliases/Context/AccesibilityContext.php | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/class_aliases/Context/AccesibilityContext.php diff --git a/src/class_aliases/Context/AccesibilityContext.php b/src/class_aliases/Context/AccesibilityContext.php new file mode 100644 index 00000000..85ab9ef7 --- /dev/null +++ b/src/class_aliases/Context/AccesibilityContext.php @@ -0,0 +1,5 @@ +