Skip to content
This repository
Browse code

Merge branch 'release/1.4.1'

  • Loading branch information...
commit c76a5e0f1f92c627445ae17d7bb6bce4c2a3dd6e 2 parents 71a9705 + 820015e
Konstantin Kudryashov everzet authored

Showing 28 changed files with 415 additions and 472 deletions. Show diff stats Hide diff stats

  1. +8 2 .travis.yml
  2. +11 0 CHANGES.md
  3. +13 13 bin/release
  4. +7 10 composer.json
  5. +1 1  phpunit.xml.dist
  6. +1 1  src/Behat/Mink/ClassLoader/MapFileClassLoader.php
  7. +0 121 src/Behat/Mink/Compiler/MapFileCompiler.php
  8. +0 227 src/Behat/Mink/Compiler/PearCompiler.php
  9. +6 5 src/Behat/Mink/Compiler/PharCompiler.php
  10. +62 45 src/Behat/Mink/Driver/DriverInterface.php
  11. +7 7 src/Behat/Mink/Element/ElementInterface.php
  12. +36 7 src/Behat/Mink/Element/NodeElement.php
  13. +16 0 src/Behat/Mink/Element/TraversableElement.php
  14. +2 2 src/Behat/Mink/Exception/DriverException.php
  15. +59 0 src/Behat/Mink/Exception/ElementException.php
  16. +1 1  src/Behat/Mink/Exception/Exception.php
  17. +0 2  src/Behat/Mink/Exception/ResponseTextException.php
  18. +6 3 src/Behat/Mink/Mink.php
  19. +3 3 src/Behat/Mink/Selector/NamedSelector.php
  20. +1 1  src/Behat/Mink/Selector/SelectorInterface.php
  21. +23 0 src/Behat/Mink/Session.php
  22. +36 12 src/Behat/Mink/WebAssert.php
  23. +9 1 tests/Behat/Mink/Driver/GeneralDriverTest.php
  24. +14 0 tests/Behat/Mink/Driver/JavascriptDriverTest.php
  25. +33 0 tests/Behat/Mink/Driver/web-fixtures/issue255.php
  26. +4 4 tests/Behat/Mink/Element/DocumentElementTest.php
  27. +15 0 tests/Behat/Mink/Element/NodeElementTest.php
  28. +41 4 tests/Behat/Mink/WebAssertTest.php
10 .travis.yml
@@ -4,6 +4,11 @@ php:
4 4 - 5.3
5 5 - 5.4
6 6
  7 +env:
  8 + - SYMFONY_VERSION='2.0.*'
  9 + - SYMFONY_VERSION='2.1.*'
  10 + - SYMFONY_VERSION='2.2.*@dev'
  11 +
7 12 branches:
8 13 only:
9 14 - master
@@ -11,6 +16,7 @@ branches:
11 16
12 17 before_script:
13 18 - curl http://getcomposer.org/installer | php
14   - - php composer.phar install
  19 + - php composer.phar require --no-update symfony/symfony=$SYMFONY_VERSION
  20 + - php composer.phar install --dev --prefer-source
15 21
16   -script: phpunit
  22 +script: phpunit -v
11 CHANGES.md
Source Rendered
... ... @@ -1,3 +1,14 @@
  1 +1.4.1 / 2013-02-10
  2 +==================
  3 +
  4 + * Update dependencies
  5 + * Add ElementException to element actions
  6 + * Rel attribute support for named selectors
  7 + * Add hasClass() helper to traversable elements
  8 + * Add getScreenshot() method to session
  9 + * Name attr support in named selector for button
  10 + * Fix for bunch of bugs
  11 +
1 12 1.4.0 / 2012-05-40
2 13 ==================
3 14
26 bin/release
@@ -17,12 +17,8 @@
17 17 * @author Konstantin Kudryashov <ever.zet@gmail.com>
18 18 */
19 19
20   -require_once __DIR__ . '/../vendor/autoload.php';
21   -
22 20 use Behat\Mink\Compiler;
23 21
24   -system('rm *.phar *.tgz');
25   -
26 22 if (!isset($argv[1])) {
27 23 throw new RuntimeException('You must provide version.');
28 24 }
@@ -33,20 +29,24 @@ if (!isset($argv[2])) {
33 29 }
34 30 $stability = $argv[2];
35 31
36   -$ldr = new Compiler\MapFileCompiler($autoloaderFilename = 'autoload.php', $mapFilename = 'autoload_map.php');
37   -$ldr->compile();
38   -echo "Autoloader compiled\n";
  32 +system('rm -rf vendor composer.lock');
  33 +system('cp composer.json composer.json.back');
  34 +system('composer require --no-update "behat/mink-goutte-driver=@dev"');
  35 +system('composer require --no-update "behat/mink-sahi-driver=@dev"');
  36 +system('composer require --no-update "behat/mink-selenium-driver=@dev"');
  37 +system('composer require --no-update "behat/mink-selenium2-driver=@dev"');
  38 +system('composer require --no-update "behat/mink-zombie-driver=@dev"');
  39 +system('composer install --prefer-dist');
39 40
40   -$pear = new Compiler\PearCompiler();
41   -$pear->compile($version, $stability);
42   -echo "PEAR package compiled: mink-$version.tgz\n";
  41 +require_once __DIR__ . '/../vendor/autoload.php';
43 42
  43 +system('rm *.phar');
44 44 $phar = new Compiler\PharCompiler();
45 45 $phar->compile($version);
46 46 system("cp mink-$version.phar mink.phar");
47 47 echo "PHAR package compiled: mink-$version.phar\n";
48 48
49   -unlink($autoloaderFilename);
50   -unlink($mapFilename);
51   -
  49 +system('mv composer.json.back composer.json');
  50 +system('rm -rf vendor composer.lock');
  51 +system('composer install --dev --prefer-dist');
52 52 exit(0);
17 composer.json
@@ -16,16 +16,7 @@
16 16
17 17 "require": {
18 18 "php": ">=5.3.1",
19   - "symfony/css-selector": ">=2.0.0,<2.2.0-dev"
20   - },
21   -
22   - "require-dev": {
23   - "behat/mink-goutte-driver": "*",
24   - "behat/mink-sahi-driver": "*",
25   - "behat/mink-selenium-driver": "*",
26   - "behat/mink-selenium2-driver": "*",
27   - "behat/mink-zombie-driver": "*",
28   - "symfony/finder": ">=2.0.0,<2.2.0-dev"
  19 + "symfony/css-selector": ">=2.0,<2.3-dev"
29 20 },
30 21
31 22 "suggest": {
@@ -40,5 +31,11 @@
40 31 "psr-0": {
41 32 "Behat\\Mink": "src/"
42 33 }
  34 + },
  35 +
  36 + "extra": {
  37 + "branch-alias": {
  38 + "dev-develop": "1.4-dev"
  39 + }
43 40 }
44 41 }
2  phpunit.xml.dist
@@ -2,7 +2,7 @@
2 2
3 3 <phpunit backupGlobals="false"
4 4 backupStaticAttributes="false"
5   - colors="false"
  5 + colors="true"
6 6 convertErrorsToExceptions="true"
7 7 convertNoticesToExceptions="true"
8 8 convertWarningsToExceptions="true"
2  src/Behat/Mink/ClassLoader/MapFileClassLoader.php
@@ -73,4 +73,4 @@ public function findFile($class)
73 73 return $this->map[$class];
74 74 }
75 75 }
76   -}
  76 +}
121 src/Behat/Mink/Compiler/MapFileCompiler.php
... ... @@ -1,121 +0,0 @@
1   -<?php
2   -
3   -namespace Behat\Mink\Compiler;
4   -
5   -use Symfony\Component\Finder\Finder;
6   -
7   -/*
8   - * This file is part of the Behat\Mink.
9   - * (c) Konstantin Kudryashov <ever.zet@gmail.com>
10   - *
11   - * For the full copyright and license information, please view the LICENSE
12   - * file that was distributed with this source code.
13   - */
14   -
15   -/**
16   - * Class loader map file compiler.
17   - *
18   - * @author Konstantin Kudryashov <ever.zet@gmail.com>
19   - */
20   -class MapFileCompiler
21   -{
22   - /**
23   - * Behat lib directory.
24   - *
25   - * @var string
26   - */
27   - private $libPath;
28   -
29   - /**
30   - * Initializes compiler.
31   - */
32   - public function __construct()
33   - {
34   - $this->libPath = realpath(__DIR__ . '/../../../../');
35   - }
36   -
37   - /**
38   - * Compiles map file and autoloader.
39   - *
40   - * @param string $version
41   - */
42   - public function compile($autoloaderFilename = 'autoload.php', $mapFilename = 'autoload_map.php')
43   - {
44   - if (file_exists($mapFilename)) {
45   - unlink($mapFilename);
46   - }
47   - $mappings = '';
48   -
49   - // autoload Symfony2
50   - $mappings .= "\nif (!defined('BEHAT_AUTOLOAD_SF2') || true === BEHAT_AUTOLOAD_SF2) {\n";
51   - foreach ($this->findPhpFile()->in($this->libPath . '/vendor/symfony') as $file) {
52   - $path = str_replace(array(
53   - $this->libPath . '/vendor/symfony/browser-kit/',
54   - $this->libPath . '/vendor/symfony/css-selector/',
55   - $this->libPath . '/vendor/symfony/dom-crawler/',
56   - $this->libPath . '/vendor/symfony/process/',
57   - ), '', $file->getRealPath());
58   - $class = str_replace(array('/', '.php'), array('\\', ''), $path);
59   - $mappings .= " \$mappings['$class'] = '$path';\n";
60   - }
61   - $mappings .= "}\n";
62   -
63   - $mapContent = <<<MAP_FILE
64   -<?php
65   -
66   -\$mappings = array();
67   -$mappings
68   -return \$mappings;
69   -MAP_FILE;
70   -
71   - file_put_contents($mapFilename, $mapContent);
72   - file_put_contents($autoloaderFilename, $this->getAutoloadScript($mapFilename));
73   - }
74   -
75   - /**
76   - * Returns autoload.php content.
77   - *
78   - * @param string $mapFilename
79   - *
80   - * @return string
81   - */
82   - protected function getAutoloadScript($mapFilename)
83   - {
84   - return sprintf(<<<'EOF'
85   -<?php
86   -
87   -/*
88   - * This file is part of the Behat\Mink.
89   - * (c) Konstantin Kudryashov <ever.zet@gmail.com>
90   - *
91   - * For the full copyright and license information, please view the LICENSE
92   - * file that was distributed with this source code.
93   - */
94   -
95   -if (!class_exists('Behat\Mink\ClassLoader\MapFileClassLoader')) {
96   - require_once __DIR__ . '/src/Behat/Mink/ClassLoader/MapFileClassLoader.php';
97   -}
98   -
99   -use Behat\Mink\ClassLoader\MapFileClassLoader;
100   -
101   -$loader = new MapFileClassLoader(__DIR__ . '/%s');
102   -$loader->register();
103   -
104   -require_once __DIR__ . '/vendor/autoload.php';
105   -
106   -EOF
107   - , $mapFilename);
108   - }
109   -
110   - /**
111   - * Creates finder instance to search php files.
112   - *
113   - * @return Symfony\Component\Finder\Finder
114   - */
115   - private function findPhpFile()
116   - {
117   - $finder = new Finder();
118   -
119   - return $finder->files()->ignoreVCS(true)->name('*.php');
120   - }
121   -}
227 src/Behat/Mink/Compiler/PearCompiler.php
... ... @@ -1,227 +0,0 @@
1   -<?php
2   -
3   -namespace Behat\Mink\Compiler;
4   -
5   -use Symfony\Component\Finder\Finder;
6   -
7   -/*
8   - * This file is part of the Behat\Mink.
9   - * (c) Konstantin Kudryashov <ever.zet@gmail.com>
10   - *
11   - * For the full copyright and license information, please view the LICENSE
12   - * file that was distributed with this source code.
13   - */
14   -
15   -/**
16   - * Pear package compiler.
17   - *
18   - * @author Konstantin Kudryashov <ever.zet@gmail.com>
19   - */
20   -class PearCompiler
21   -{
22   - /**
23   - * Behat lib directory.
24   - *
25   - * @var string
26   - */
27   - private $libPath;
28   -
29   - /**
30   - * Initializes compiler.
31   - */
32   - public function __construct()
33   - {
34   - $this->libPath = realpath(__DIR__ . '/../../../../');
35   - }
36   -
37   - /**
38   - * Compiles pear package.
39   - *
40   - * @param string $version
41   - */
42   - public function compile($version, $stability)
43   - {
44   - if (file_exists('package.xml')) {
45   - unlink('package.xml');
46   - }
47   - file_put_contents('package.xml', $this->getPackageTemplate());
48   -
49   - $finder = new Finder();
50   - $finder->files()
51   - ->ignoreVCS(true)
52   - ->name('*.php')
53   - ->name('*.xliff')
54   - ->name('*.xml')
55   - ->name('*.js')
56   - ->name('*.feature')
57   - ->name('LICENSE')
58   - ->name('LICENSE.txt')
59   - ->notName('test')
60   - ->notName('tests')
61   - ->exclude(array(
62   - 'Compiler',
63   - 'finder',
64   - 'test',
65   - 'tests',
66   - 'vendor',
67   - ))
68   - ->in($this->libPath . '/src')
69   - ->in($this->libPath . '/vendor/composer')
70   - ->in($this->libPath . '/vendor/alexandresalome')
71   - ->in($this->libPath . '/vendor/behat')
72   - ->in($this->libPath . '/vendor/fabpot')
73   - ->in($this->libPath . '/vendor/kriswallsmith')
74   - ->in($this->libPath . '/vendor/guzzle')
75   - ->in($this->libPath . '/vendor/instaclick')
76   - ;
77   -
78   - $xmlSourceFiles = '';
79   - foreach ($finder as $file) {
80   - if (!$file instanceof \SplFileInfo) {
81   - $file = new \SplFileInfo($file);
82   - }
83   -
84   - $path = str_replace($this->libPath . '/', '', $file->getRealPath());
85   - $xmlSourceFiles .=
86   - '<file role="php" baseinstalldir="mink" install-as="'.$path.'" name="'.$path.'" />'."\n";
87   - }
88   -
89   - $this->replaceTokens('package.xml', '##', '##', array(
90   - 'MINK_VERSION' => $version,
91   - 'CURRENT_DATE' => date('Y-m-d'),
92   - 'SOURCE_FILES' => $xmlSourceFiles,
93   - 'STABILITY' => $stability
94   - ));
95   -
96   - system('pear package');
97   - unlink('package.xml');
98   - }
99   -
100   - /**
101   - * Replaces tokens in specified path.
102   - *
103   - * @param string|array $files files array or single file
104   - * @param string $tokenStart token start symbol
105   - * @param string $tokenFinish token finish symbol
106   - * @param array $tokens replace tokens array
107   - */
108   - protected function replaceTokens($files, $tokenStart, $tokenFinish, array $tokens)
109   - {
110   - if (!is_array($files)) {
111   - $files = array($files);
112   - }
113   -
114   - foreach ($files as $file) {
115   - $content = file_get_contents($file);
116   - foreach ($tokens as $key => $value) {
117   - $content = str_replace($tokenStart . $key . $tokenFinish, $value, $content, $count);
118   - }
119   - file_put_contents($file, $content);
120   - }
121   - }
122   -
123   - /**
124   - * Returns pear package template.
125   - *
126   - * @return string
127   - */
128   - protected function getPackageTemplate()
129   - {
130   - return <<<'EOF'
131   -<?xml version="1.0" encoding="UTF-8"?>
132   -<package packagerversion="1.8.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
133   - http://pear.php.net/dtd/tasks-1.0.xsd
134   - http://pear.php.net/dtd/package-2.0
135   - http://pear.php.net/dtd/package-2.0.xsd">
136   - <name>mink</name>
137   - <channel>pear.behat.org</channel>
138   - <summary>Behat\Mink is an browser emulation framework for PHP</summary>
139   - <description>
140   - Behat\Mink is an open source browser emulation framework for php 5.3.
141   - </description>
142   - <lead>
143   - <name>Konstantin Kudryashov</name>
144   - <user>everzet</user>
145   - <email>ever.zet@gmail.com</email>
146   - <active>yes</active>
147   - </lead>
148   - <date>##CURRENT_DATE##</date>
149   - <version>
150   - <release>##MINK_VERSION##</release>
151   - <api>1.0.0</api>
152   - </version>
153   - <stability>
154   - <release>##STABILITY##</release>
155   - <api>##STABILITY##</api>
156   - </stability>
157   - <license uri="http://www.opensource.org/licenses/mit-license.php">MIT</license>
158   - <notes>-</notes>
159   - <contents>
160   - <dir name="/">
161   - ##SOURCE_FILES##
162   -
163   - <file role="php" baseinstalldir="mink" name="autoload.php" />
164   - <file role="php" baseinstalldir="mink" name="autoload_map.php" />
165   - <file role="php" baseinstalldir="mink" name="CHANGES.md" />
166   - <file role="php" baseinstalldir="mink" name="LICENSE" />
167   - <file role="php" baseinstalldir="mink" name="README.md" />
168   - </dir>
169   - </contents>
170   - <dependencies>
171   - <required>
172   - <php>
173   - <min>5.3.1</min>
174   - </php>
175   - <pearinstaller>
176   - <min>1.4.0</min>
177   - </pearinstaller>
178   - <package>
179   - <name>BrowserKit</name>
180   - <channel>pear.symfony.com</channel>
181   - </package>
182   - <package>
183   - <name>CssSelector</name>
184   - <channel>pear.symfony.com</channel>
185   - </package>
186   - <package>
187   - <name>DomCrawler</name>
188   - <channel>pear.symfony.com</channel>
189   - </package>
190   - <package>
191   - <name>Process</name>
192   - <channel>pear.symfony.com</channel>
193   - </package>
194   - <extension>
195   - <name>pcre</name>
196   - </extension>
197   - <extension>
198   - <name>simplexml</name>
199   - </extension>
200   - <extension>
201   - <name>xml</name>
202   - </extension>
203   - </required>
204   - <optional>
205   - <package>
206   - <name>PHPUnit</name>
207   - <channel>pear.phpunit.de</channel>
208   - </package>
209   - </optional>
210   - </dependencies>
211   - <phprelease />
212   -</package>
213   -EOF;
214   - }
215   -
216   - /**
217   - * Creates finder instance to search php files.
218   - *
219   - * @return Symfony\Component\Finder\Finder
220   - */
221   - private function findPhpFile()
222   - {
223   - $finder = new Finder();
224   -
225   - return $finder->files()->ignoreVCS(true)->name('*.php');
226   - }
227   -}
11 src/Behat/Mink/Compiler/PharCompiler.php
@@ -37,7 +37,7 @@ public function __construct()
37 37 /**
38 38 * Compiles phar archive.
39 39 *
40   - * @param string $version
  40 + * @param string $version
41 41 */
42 42 public function compile($version)
43 43 {
@@ -87,6 +87,7 @@ public function compile($version)
87 87
88 88 $this->addFileToPhar($file, $phar);
89 89 }
  90 + $this->addFileToPhar(new \SplFileInfo('vendor/autoload.php'), $phar);
90 91
91 92 // stub
92 93 $phar->setStub($this->getStub($version));
@@ -98,8 +99,8 @@ public function compile($version)
98 99 /**
99 100 * Adds a file to phar archive.
100 101 *
101   - * @param SplFileInfo $file file info
102   - * @param Phar $phar phar packager
  102 + * @param SplFileInfo $file file info
  103 + * @param Phar $phar phar packager
103 104 */
104 105 protected function addFileToPhar(\SplFileInfo $file, \Phar $phar)
105 106 {
@@ -110,9 +111,9 @@ protected function addFileToPhar(\SplFileInfo $file, \Phar $phar)
110 111 /**
111 112 * Returns autoloader stub.
112 113 *
113   - * @param string $version
  114 + * @param string $version
114 115 *
115   - * @return string
  116 + * @return string
116 117 */
117 118 protected function getStub($version)
118 119 {
107 src/Behat/Mink/Driver/DriverInterface.php
@@ -24,58 +24,58 @@
24 24 *
25 25 * @param Session $session
26 26 */
27   - function setSession(Session $session);
  27 + public function setSession(Session $session);
28 28
29 29 /**
30 30 * Starts driver.
31 31 */
32   - function start();
  32 + public function start();
33 33
34 34 /**
35 35 * Checks whether driver is started.
36 36 *
37 37 * @return Boolean
38 38 */
39   - function isStarted();
  39 + public function isStarted();
40 40
41 41 /**
42 42 * Stops driver.
43 43 */
44   - function stop();
  44 + public function stop();
45 45
46 46 /**
47 47 * Resets driver.
48 48 */
49   - function reset();
  49 + public function reset();
50 50
51 51 /**
52 52 * Visit specified URL.
53 53 *
54 54 * @param string $url url of the page
55 55 */
56   - function visit($url);
  56 + public function visit($url);
57 57
58 58 /**
59 59 * Returns current URL address.
60 60 *
61 61 * @return string
62 62 */
63   - function getCurrentUrl();
  63 + public function getCurrentUrl();
64 64
65 65 /**
66 66 * Reloads current page.
67 67 */
68   - function reload();
  68 + public function reload();
69 69
70 70 /**
71 71 * Moves browser forward 1 page.
72 72 */
73   - function forward();
  73 + public function forward();
74 74
75 75 /**
76 76 * Moves browser backward 1 page.
77 77 */
78   - function back();
  78 + public function back();
79 79
80 80 /**
81 81 * Sets HTTP Basic authentication parameters
@@ -83,21 +83,21 @@ function back();
83 83 * @param string|Boolean $user user name or false to disable authentication
84 84 * @param string $password password
85 85 */
86   - function setBasicAuth($user, $password);
  86 + public function setBasicAuth($user, $password);
87 87
88 88 /**
89 89 * Switches to specific browser window.
90 90 *
91 91 * @param string $name window name (null for switching back to main window)
92 92 */
93   - function switchToWindow($name = null);
  93 + public function switchToWindow($name = null);
94 94
95 95 /**
96 96 * Switches to specific iFrame.
97 97 *
98 98 * @param string $name iframe name (null for switching back)
99 99 */
100   - function switchToIFrame($name = null);
  100 + public function switchToIFrame($name = null);
101 101
102 102 /**
103 103 * Sets specific request header on client.
@@ -105,14 +105,14 @@ function switchToIFrame($name = null);
105 105 * @param string $name
106 106 * @param string $value
107 107 */
108   - function setRequestHeader($name, $value);
  108 + public function setRequestHeader($name, $value);
109 109
110 110 /**
111 111 * Returns last response headers.
112 112 *
113 113 * @return array
114 114 */
115   - function getResponseHeaders();
  115 + public function getResponseHeaders();
116 116
117 117 /**
118 118 * Sets cookie.
@@ -120,7 +120,7 @@ function getResponseHeaders();
120 120 * @param string $name
121 121 * @param string $value
122 122 */
123   - function setCookie($name, $value = null);
  123 + public function setCookie($name, $value = null);
124 124
125 125 /**
126 126 * Returns cookie by name.
@@ -129,21 +129,29 @@ function setCookie($name, $value = null);
129 129 *
130 130 * @return string|null
131 131 */
132   - function getCookie($name);
  132 + public function getCookie($name);
133 133
134 134 /**
135 135 * Returns last response status code.
136 136 *
137 137 * @return integer
138 138 */
139   - function getStatusCode();
  139 + public function getStatusCode();
140 140
141 141 /**
142 142 * Returns last response content.
143 143 *
144 144 * @return string
145 145 */
146   - function getContent();
  146 + public function getContent();
  147 +
  148 + /**
  149 + * Capture a screenshot of the current window.
  150 + *
  151 + * @return string screenshot of MIME type image/* depending
  152 + * on driver (e.g., image/png, image/jpeg)
  153 + */
  154 + public function getScreenshot();
147 155
148 156 /**
149 157 * Finds elements with specified XPath query.
@@ -152,7 +160,7 @@ function getContent();
152 160 *
153 161 * @return array array of NodeElements
154 162 */
155   - function find($xpath);
  163 + public function find($xpath);
156 164
157 165 /**
158 166 * Returns element's tag name by it's XPath query.
@@ -161,7 +169,7 @@ function find($xpath);
161 169 *
162 170 * @return string
163 171 */
164   - function getTagName($xpath);
  172 + public function getTagName($xpath);
165 173
166 174 /**
167 175 * Returns element's text by it's XPath query.
@@ -170,7 +178,7 @@ function getTagName($xpath);
170 178 *
171 179 * @return string
172 180 */
173   - function getText($xpath);
  181 + public function getText($xpath);
174 182
175 183 /**
176 184 * Returns element's html by it's XPath query.
@@ -179,7 +187,7 @@ function getText($xpath);
179 187 *
180 188 * @return string
181 189 */
182   - function getHtml($xpath);
  190 + public function getHtml($xpath);
183 191
184 192 /**
185 193 * Returns element's attribute by it's XPath query.
@@ -189,7 +197,7 @@ function getHtml($xpath);
189 197 *
190 198 * @return mixed
191 199 */
192   - function getAttribute($xpath, $name);
  200 + public function getAttribute($xpath, $name);
193 201
194 202 /**
195 203 * Returns element's value by it's XPath query.
@@ -198,7 +206,7 @@ function getAttribute($xpath, $name);
198 206 *
199 207 * @return mixed
200 208 */
201   - function getValue($xpath);
  209 + public function getValue($xpath);
202 210
203 211 /**
204 212 * Sets element's value by it's XPath query.
@@ -206,21 +214,21 @@ function getValue($xpath);
206 214 * @param string $xpath
207 215 * @param string $value
208 216 */
209   - function setValue($xpath, $value);
  217 + public function setValue($xpath, $value);
210 218
211 219 /**
212 220 * Checks checkbox by it's XPath query.
213 221 *
214 222 * @param string $xpath
215 223 */
216   - function check($xpath);
  224 + public function check($xpath);
217 225
218 226 /**
219 227 * Unchecks checkbox by it's XPath query.
220 228 *
221 229 * @param string $xpath
222 230 */
223   - function uncheck($xpath);
  231 + public function uncheck($xpath);
224 232
225 233 /**
226 234 * Checks whether checkbox checked located by it's XPath query.
@@ -229,7 +237,7 @@ function uncheck($xpath);
229 237 *
230 238 * @return Boolean
231 239 */
232   - function isChecked($xpath);
  240 + public function isChecked($xpath);
233 241
234 242 /**
235 243 * Selects option from select field located by it's XPath query.
@@ -238,28 +246,28 @@ function isChecked($xpath);
238 246 * @param string $value
239 247 * @param Boolean $multiple
240 248 */
241   - function selectOption($xpath, $value, $multiple = false);
  249 + public function selectOption($xpath, $value, $multiple = false);
242 250
243 251 /**
244 252 * Clicks button or link located by it's XPath query.
245 253 *
246 254 * @param string $xpath
247 255 */
248   - function click($xpath);
  256 + public function click($xpath);
249 257
250 258 /**
251 259 * Double-clicks button or link located by it's XPath query.
252 260 *
253 261 * @param string $xpath
254 262 */
255   - function doubleClick($xpath);
  263 + public function doubleClick($xpath);
256 264
257 265 /**
258 266 * Right-clicks button or link located by it's XPath query.
259 267 *
260 268 * @param string $xpath
261 269 */
262   - function rightClick($xpath);
  270 + public function rightClick($xpath);
263 271
264 272 /**
265 273 * Attaches file path to file field located by it's XPath query.
@@ -267,7 +275,7 @@ function rightClick($xpath);
267 275 * @param string $xpath
268 276 * @param string $path
269 277 */
270   - function attachFile($xpath, $path);
  278 + public function attachFile($xpath, $path);
271 279
272 280 /**
273 281 * Checks whether element visible located by it's XPath query.
@@ -276,28 +284,28 @@ function attachFile($xpath, $path);
276 284 *
277 285 * @return Boolean
278 286 */
279   - function isVisible($xpath);
  287 + public function isVisible($xpath);
280 288
281 289 /**
282 290 * Simulates a mouse over on the element.
283 291 *
284 292 * @param string $xpath
285 293 */
286   - function mouseOver($xpath);
  294 + public function mouseOver($xpath);
287 295
288 296 /**
289 297 * Brings focus to element.
290 298 *
291 299 * @param string $xpath
292 300 */
293   - function focus($xpath);
  301 + public function focus($xpath);
294 302
295 303 /**
296 304 * Removes focus from element.
297 305 *
298 306 * @param string $xpath
299 307 */
300   - function blur($xpath);
  308 + public function blur($xpath);
301 309
302 310 /**
303 311 * Presses specific keyboard key.
@@ -306,7 +314,7 @@ function blur($xpath);
306 314 * @param mixed $char could be either char ('b') or char-code (98)
307 315 * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta')
308 316 */
309   - function keyPress($xpath, $char, $modifier = null);
  317 + public function keyPress($xpath, $char, $modifier = null);
310 318
311 319 /**
312 320 * Pressed down specific keyboard key.
@@ -315,7 +323,7 @@ function keyPress($xpath, $char, $modifier = null);
315 323 * @param mixed $char could be either char ('b') or char-code (98)
316 324 * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta')
317 325 */
318   - function keyDown($xpath, $char, $modifier = null);
  326 + public function keyDown($xpath, $char, $modifier = null);
319 327
320 328 /**
321 329 * Pressed up specific keyboard key.
@@ -324,7 +332,7 @@ function keyDown($xpath, $char, $modifier = null);
324 332 * @param mixed $char could be either char ('b') or char-code (98)
325 333 * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta')
326 334 */
327   - function keyUp($xpath, $char, $modifier = null);
  335 + public function keyUp($xpath, $char, $modifier = null);
328 336
329 337 /**
330 338 * Drag one element onto another.
@@ -332,14 +340,14 @@ function keyUp($xpath, $char, $modifier = null);
332 340 * @param string $sourceXpath
333 341 * @param string $destinationXpath
334 342 */
335   - function dragTo($sourceXpath, $destinationXpath);
  343 + public function dragTo($sourceXpath, $destinationXpath);
336 344
337 345 /**
338 346 * Executes JS script.
339 347 *
340 348 * @param string $script
341 349 */
342   - function executeScript($script);
  350 + public function executeScript($script);
343 351
344 352 /**
345 353 * Evaluates JS script.
@@ -348,7 +356,7 @@ function executeScript($script);
348 356 *
349 357 * @return mixed
350 358 */
351   - function evaluateScript($script);
  359 + public function evaluateScript($script);
352 360
353 361 /**
354 362 * Waits some time or until JS condition turns true.
@@ -356,5 +364,14 @@ function evaluateScript($script);
356 364 * @param integer $time time in milliseconds
357 365 * @param string $condition JS condition
358 366 */
359   - function wait($time, $condition);
  367 + public function wait($time, $condition);
  368 +
  369 + /**
  370 + * Set the dimensions of the window.
  371 + *
  372 + * @param integer $width set the window width, measured in pixels
  373 + * @param integer $height set the window height, measured in pixels
  374 + * @param string $name window name (null for the main window)
  375 + */
  376 + public function resizeWindow($width, $height, $name = null);
360 377 }
14 src/Behat/Mink/Element/ElementInterface.php
@@ -24,14 +24,14 @@
24 24 *
25 25 * @return string
26 26 */
27   - function getXpath();
  27 + public function getXpath();
28 28
29 29 /**
30 30 * Returns element's session.
31 31 *
32 32 * @return Session
33 33 */
34   - function getSession();
  34 + public function getSession();
35 35
36 36 /**
37 37 * Checks whether element with specified selector exists.
@@ -41,7 +41,7 @@ function getSession();
41 41 *
42 42 * @return Boolean
43 43 */
44   - function has($selector, $locator);
  44 + public function has($selector, $locator);
45 45
46 46 /**
47 47 * Finds first element with specified selector.
@@ -51,7 +51,7 @@ function has($selector, $locator);
51 51 *
52 52 * @return NodeElement|null
53 53 */
54   - function find($selector, $locator);
  54 + public function find($selector, $locator);
55 55
56 56 /**
57 57 * Finds all elements with specified selector.
@@ -61,19 +61,19 @@ function find($selector, $locator);
61 61 *
62 62 * @return array
63 63 */
64   - function findAll($selector, $locator);
  64 + public function findAll($selector, $locator);
65 65
66 66 /**
67 67 * Returns element text (inside tag).
68 68 *
69 69 * @return string|null
70 70 */
71   - function getText();
  71 + public function getText();
72 72
73 73 /**
74 74 * Returns element html.
75 75 *
76 76 * @return string|null
77 77 */
78   - function getHtml();
  78 + public function getHtml();
79 79 }
43 src/Behat/Mink/Element/NodeElement.php
@@ -5,6 +5,7 @@
5 5 use Behat\Mink\Session,
6 6 Behat\Mink\Driver\DriverInterface,
7 7 Behat\Mink\Element\ElementInterface,
  8 + Behat\Mink\Exception\ElementException,
8 9 Behat\Mink\Exception\ElementNotFoundException;
9 10
10 11 /*
@@ -84,7 +85,11 @@ public function getValue()
84 85 */
85 86 public function setValue($value)
86 87 {
87   - $this->getSession()->getDriver()->setValue($this->getXpath(), $value);
  88 + try {
  89 + $this->getSession()->getDriver()->setValue($this->getXpath(), $value);
  90 + } catch (\Exception $exception) {
  91 + throw new ElementException($this, $exception);
  92 + }
88 93 }
89 94
90 95 /**
@@ -116,7 +121,11 @@ public function getAttribute($name)
116 121 */
117 122 public function click()
118 123 {
119   - $this->getSession()->getDriver()->click($this->getXpath());
  124 + try {
  125 + $this->getSession()->getDriver()->click($this->getXpath());
  126 + } catch (\Exception $exception) {
  127 + throw new ElementException($this, $exception);
  128 + }
120 129 }
121 130
122 131 /**
@@ -132,7 +141,11 @@ public function press()
132 141 */
133 142 public function doubleClick()
134 143 {
135   - $this->getSession()->getDriver()->doubleClick($this->getXpath());
  144 + try {
  145 + $this->getSession()->getDriver()->doubleClick($this->getXpath());
  146 + } catch (\Exception $exception) {
  147 + throw new ElementException($this, $exception);
  148 + }
136 149 }
137 150
138 151 /**
@@ -140,7 +153,11 @@ public function doubleClick()
140 153 */
141 154 public function rightClick()
142 155 {
143   - $this->getSession()->getDriver()->rightClick($this->getXpath());
  156 + try {
  157 + $this->getSession()->getDriver()->rightClick($this->getXpath());
  158 + } catch (\Exception $exception) {
  159 + throw new ElementException($this, $exception);
  160 + }
144 161 }
145 162
146 163 /**
@@ -148,7 +165,11 @@ public function rightClick()
148 165 */
149 166 public function check()
150 167 {
151   - $this->getSession()->getDriver()->check($this->getXpath());
  168 + try {
  169 + $this->getSession()->getDriver()->check($this->getXpath());
  170 + } catch (\Exception $exception) {
  171 + throw new ElementException($this, $exception);
  172 + }
152 173 }
153 174
154 175 /**
@@ -156,7 +177,11 @@ public function check()
156 177 */
157 178 public function uncheck()
158 179 {
159   - $this->getSession()->getDriver()->uncheck($this->getXpath());
  180 + try {
  181 + $this->getSession()->getDriver()->uncheck($this->getXpath());
  182 + } catch (\Exception $exception) {
  183 + throw new ElementException($this, $exception);
  184 + }
160 185 }
161 186
162 187 /**
@@ -207,7 +232,11 @@ public function selectOption($option, $multiple = false)
207 232 */
208 233 public function attachFile($path)
209 234 {
210   - $this->getSession()->getDriver()->attachFile($this->getXpath(), $path);
  235 + try {
  236 + $this->getSession()->getDriver()->attachFile($this->getXpath(), $path);
  237 + } catch (\Exception $exception) {
  238 + throw new ElementException($this, $exception);
  239 + }
211 240 }
212 241
213 242 /**
16 src/Behat/Mink/Element/TraversableElement.php
@@ -92,6 +92,22 @@ public function hasButton($locator)
92 92 }
93 93
94 94 /**
  95 + * Checks whether an element has a named CSS class
  96 + *
  97 + * @param string $className Name of the class
  98 + *
  99 + * @return boolean
  100 + */
  101 + public function hasClass($className)
  102 + {
  103 + if ($this->hasAttribute('class')) {
  104 + return in_array($className, explode(' ', $this->getAttribute('class')));
  105 + }
  106 +
  107 + return false;
  108 + }
  109 +
  110 + /**
95 111 * Finds button (input[type=submit|image|button], button) with specified locator.
96 112 *
97 113 * @param string $locator button id, value or alt
4 src/Behat/Mink/Exception/DriverException.php
@@ -20,8 +20,8 @@ class DriverException extends Exception
20 20 /**
21 21 * Initializes exception.
22 22 *
23   - * @param string $message
24   - * @param int $code
  23 + * @param string $message
  24 + * @param int $code
25 25 * @param \Exception|null $previous
26 26 */
27 27 public function __construct($message, $code = 0, \Exception $previous = null)
59 src/Behat/Mink/Exception/ElementException.php
... ... @@ -0,0 +1,59 @@
  1 +<?php
  2 +
  3 +namespace Behat\Mink\Exception;
  4 +
  5 +use Behat\Mink\Element\Element;
  6 +
  7 +/*
  8 + * This file is part of the Behat\Mink.
  9 + * (c) Konstantin Kudryashov <ever.zet@gmail.com>
  10 + *
  11 + * For the full copyright and license information, please view the LICENSE
  12 + * file that was distributed with this source code.