4 * This file is part of the Mink package.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Mink\Exception;
13 use Behat\Mink\Driver\DriverInterface;
14 use Behat\Mink\Session;
17 * Exception thrown when an expected element is not found.
19 * @author Konstantin Kudryashov <ever.zet@gmail.com>
21 class ElementNotFoundException extends ExpectationException
24 * Initializes exception.
26 * @param DriverInterface|Session $driver driver instance
27 * @param string $type element type
28 * @param string $selector element selector type
29 * @param string $locator element locator
31 public function __construct($driver, $type = null, $selector = null, $locator = null)
36 $message .= ucfirst($type);
41 if (null !== $locator) {
42 if (null === $selector || in_array($selector, array('css', 'xpath'))) {
43 $selector = 'matching '.($selector ?: 'locator');
45 $selector = 'with '.$selector;
47 $message .= ' '.$selector.' "'.$locator.'"';
50 $message .= ' not found.';
52 parent::__construct($message, $driver);