This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Merge pull request #585 from aik099/578-relaxed-exception-matching-in…

…-tests

Any exception thrown on missing element action will make tests pass
  • Loading branch information...
2 parents fee86c9 + 91f10a4 commit 6dcc674a198848c8958d281bb47546a1504e137f @stof stof committed Jul 13, 2014
Showing with 59 additions and 53 deletions.
  1. +59 −53 driver-testsuite/tests/Basic/ErrorHandlingTest.php
@@ -6,6 +6,12 @@
class ErrorHandlingTest extends TestCase
{
+ const NOT_FOUND_XPATH = '//html/./invalid';
+
+ const NOT_FOUND_EXCEPTION = 'Exception';
+
+ const INVALID_EXCEPTION = 'Exception';
+
public function testVisitErrorPage()
{
$this->getSession()->visit($this->pathTo('/500.php'));
@@ -24,16 +30,16 @@ public function testCheckInvalidElement()
$this->assertNotNull($element);
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
+ $this->setExpectedException(self::INVALID_EXCEPTION);
$this->getSession()->getDriver()->check($element->getXpath());
}
public function testCheckNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->check('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->check(self::NOT_FOUND_XPATH);
}
public function testUncheckInvalidElement()
@@ -43,16 +49,16 @@ public function testUncheckInvalidElement()
$this->assertNotNull($element);
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
+ $this->setExpectedException(self::INVALID_EXCEPTION);
$this->getSession()->getDriver()->uncheck($element->getXpath());
}
public function testUncheckNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->uncheck('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->uncheck(self::NOT_FOUND_XPATH);
}
public function testSelectOptionInvalidElement()
@@ -62,16 +68,16 @@ public function testSelectOptionInvalidElement()
$this->assertNotNull($element);
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
+ $this->setExpectedException(self::INVALID_EXCEPTION);
$this->getSession()->getDriver()->selectOption($element->getXpath(), 'test');
}
public function testSelectOptionNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->selectOption('//html/./invalid', 'test');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->selectOption(self::NOT_FOUND_XPATH, 'test');
}
public function testAttachFileInvalidElement()
@@ -81,16 +87,16 @@ public function testAttachFileInvalidElement()
$this->assertNotNull($element);
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
+ $this->setExpectedException(self::INVALID_EXCEPTION);
$this->getSession()->getDriver()->attachFile($element->getXpath(), __FILE__);
}
public function testAttachFileNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->attachFile('//html/./invalid', __FILE__);
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->attachFile(self::NOT_FOUND_XPATH, __FILE__);
}
public function testSubmitFormInvalidElement()
@@ -100,167 +106,167 @@ public function testSubmitFormInvalidElement()
$this->assertNotNull($element);
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
+ $this->setExpectedException(self::INVALID_EXCEPTION);
$this->getSession()->getDriver()->submitForm($element->getXpath());
}
public function testSubmitFormNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->submitForm('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->submitForm(self::NOT_FOUND_XPATH);
}
public function testGetTagNameNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->getTagName('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->getTagName(self::NOT_FOUND_XPATH);
}
public function testGetTextNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->getText('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->getText(self::NOT_FOUND_XPATH);
}
public function testGetHtmlNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->getHtml('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->getHtml(self::NOT_FOUND_XPATH);
}
public function testGetOuterHtmlNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->getOuterHtml('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->getOuterHtml(self::NOT_FOUND_XPATH);
}
public function testGetValueNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->getValue('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->getValue(self::NOT_FOUND_XPATH);
}
public function testSetValueNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->setValue('//html/./invalid', 'test');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->setValue(self::NOT_FOUND_XPATH, 'test');
}
public function testIsSelectedNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->isSelected('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->isSelected(self::NOT_FOUND_XPATH);
}
public function testIsCheckedNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->isChecked('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->isChecked(self::NOT_FOUND_XPATH);
}
public function testIsVisibleNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->isVisible('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->isVisible(self::NOT_FOUND_XPATH);
}
public function testClickNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->click('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->click(self::NOT_FOUND_XPATH);
}
public function testDoubleClickNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->doubleClick('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->doubleClick(self::NOT_FOUND_XPATH);
}
public function testRightClickNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->rightClick('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->rightClick(self::NOT_FOUND_XPATH);
}
public function testGetAttributeNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->getAttribute('//html/./invalid', 'id');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->getAttribute(self::NOT_FOUND_XPATH, 'id');
}
public function testMouseOverFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->mouseOver('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->mouseOver(self::NOT_FOUND_XPATH);
}
public function testFocusFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->focus('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->focus(self::NOT_FOUND_XPATH);
}
public function testBlurFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->blur('//html/./invalid');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->blur(self::NOT_FOUND_XPATH);
}
public function testKeyPressNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->keyPress('//html/./invalid', 'a');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->keyPress(self::NOT_FOUND_XPATH, 'a');
}
public function testKeyDownNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->keyDown('//html/./invalid', 'a');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->keyDown(self::NOT_FOUND_XPATH, 'a');
}
public function testKeyUpNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
- $this->setExpectedException('Behat\Mink\Exception\DriverException');
- $this->getSession()->getDriver()->keyUp('//html/./invalid', 'a');
+ $this->setExpectedException(self::NOT_FOUND_EXCEPTION);
+ $this->getSession()->getDriver()->keyUp(self::NOT_FOUND_XPATH, 'a');
}
}

0 comments on commit 6dcc674

Please sign in to comment.