diff --git a/src/Context/AccesibilityContext.php b/src/Context/AccesibilityContext.php new file mode 100644 index 00000000..24aed743 --- /dev/null +++ b/src/Context/AccesibilityContext.php @@ -0,0 +1,57 @@ +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"); + } + } + + /** + * @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"); + } + } +} 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 @@ +" + 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